mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-28 03:00:55 +00:00
Remove unnecessary json_encode() on post data when using json content-type
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user