Fix #459: Add example with json response as associative array

This commit is contained in:
Zach Borboa
2017-07-30 14:27:20 -07:00
parent 79e57a7341
commit a4cf524119
+21
View File
@@ -0,0 +1,21 @@
<?php
require __DIR__ . '/vendor/autoload.php';
use \Curl\Curl;
// curl \
// -X POST \
// -d "{"id":"1","content":"Hello world!","date":"2015-06-30 19:42:21"}" \
// "https://httpbin.org/post"
$data = array(
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
);
$curl = new Curl();
$curl->setDefaultJsonDecoder($assoc=true);
$curl->setHeader('Content-Type', 'application/json');
$curl->post('https://httpbin.org/post', $data);
var_dump($curl->response['json']);