From d17da3e5ee84d2abd684fba8e62193315e33b855 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Fri, 30 Sep 2016 21:44:16 -0700 Subject: [PATCH] Remove unnecessary json_encode() on post data when using json content-type --- examples/github_create_gist.php | 5 +++-- examples/gratipay_send_tip.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/github_create_gist.php b/examples/github_create_gist.php index ca06052..a9115b2 100644 --- a/examples/github_create_gist.php +++ b/examples/github_create_gist.php @@ -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"; diff --git a/examples/gratipay_send_tip.php b/examples/gratipay_send_tip.php index 3830eca..383c764 100644 --- a/examples/gratipay_send_tip.php +++ b/examples/gratipay_send_tip.php @@ -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";