Skip to content

Commit d17da3e

Browse files
committed
Remove unnecessary json_encode() on post data when using json content-type
1 parent 459231f commit d17da3e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

examples/github_create_gist.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
EOF;
1010

1111
$curl = new Curl();
12-
$curl->post('https://api.github.com/gists', json_encode(array(
12+
$curl->setHeader('Content-Type', 'application/json');
13+
$curl->post('https://api.github.com/gists', array(
1314
'description' => 'PHP-Curl-Class test.',
1415
'public' => 'true',
1516
'files' => array(
1617
'Untitled.php' => array(
1718
'content' => $content,
1819
),
1920
),
20-
)));
21+
));
2122

2223
echo 'Gist created at ' . $curl->response->html_url . "\n";

examples/gratipay_send_tip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
$curl = new Curl();
2323
$curl->setHeader('Content-Type', 'application/json');
2424
$curl->setBasicAuthentication(GRATIPAY_API_KEY);
25-
$curl->post('https://gratipay.com/' . GRATIPAY_USERNAME . '/tips.json', json_encode($data));
25+
$curl->post('https://gratipay.com/' . GRATIPAY_USERNAME . '/tips.json', $data);
2626

2727
foreach ($curl->response as $tip) {
2828
echo $tip->amount . ' given to ' . $tip->username . '.' . "\n";

0 commit comments

Comments
 (0)