Remove unnecessary json_encode() on post data when using json content-type

This commit is contained in:
Zach Borboa
2016-09-30 21:44:16 -07:00
parent 459231fae7
commit d17da3e5ee
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -9,7 +9,8 @@ echo 'hello, world';
EOF;
$curl = new Curl();
$curl->post('https://api.github.com/gists', json_encode(array(
$curl->setHeader('Content-Type', 'application/json');
$curl->post('https://api.github.com/gists', array(
'description' => 'PHP-Curl-Class test.',
'public' => 'true',
'files' => array(
@@ -17,6 +18,6 @@ $curl->post('https://api.github.com/gists', json_encode(array(
'content' => $content,
),
),
)));
));
echo 'Gist created at ' . $curl->response->html_url . "\n";
+1 -1
View File
@@ -22,7 +22,7 @@ $data = array(
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setBasicAuthentication(GRATIPAY_API_KEY);
$curl->post('https://gratipay.com/' . GRATIPAY_USERNAME . '/tips.json', json_encode($data));
$curl->post('https://gratipay.com/' . GRATIPAY_USERNAME . '/tips.json', $data);
foreach ($curl->response as $tip) {
echo $tip->amount . ' given to ' . $tip->username . '.' . "\n";