note 78629 added to function.curl-exec
| From: | mljh at c13-ss-2-lb dot cnet dot com | Date: | Fri, 19 Oct 2007 21:14:08 +0000 |
| Subject: | note 78629 added to function.curl-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131574@lists.php.net to get a copy of this message | ||
Been beating my head against the wall to figure this one out. I am calling a JSON service from PHP
using cURL. I am succesfully retrieving the response from the POST to the service (the service is
expecting a post). If I display the response, it is indeed what I expect. However, when I call
PHP's json_decode() on it, json_decode fails. After a long debugging session, I discovered that
the response from curl_exec() contains many control and unprintable characters. If I capture this
response and manually clean it up, json_decode() works as expected. Here is an example of a hex dump
of the first few characters of the response.
EF BB BF 7B 0A 20 20 22 69 64 22 3A 20 30 2C 0A
20 20 22 65 72 72 6F 72 22 3A 20 6E 75 6C 6C 2C
0A 20 20 22 72 65 73 75 6C 74 22 3A 20 7B 0A 20
20 20 20 22 55 70 6C 6F 61 64 65 64 4F 6E 22 3A
20 7B 0A 20 20 20 20 20 20 22 56 61 6C 75 65 22
3A 20 22 32 30 30 36 2D 30 36 2D
Does anyone know what is going on and more importantly, what I can do about it?
thanks!
----
Server IP: 64.71.164.2
Probable Submitter: 68.189.241.41
----
Manual Page -- http://www.php.net/manual/en/function.curl-exec.php
Edit -- https://master.php.net/note/edit/78629
Del: integrated -- https://master.php.net/note/delete/78629/integrated
Del: useless -- https://master.php.net/note/delete/78629/useless
Del: bad code -- https://master.php.net/note/delete/78629/bad+code
Del: spam -- https://master.php.net/note/delete/78629/spam
Del: non-english -- https://master.php.net/note/delete/78629/non-english
Del: in docs -- https://master.php.net/note/delete/78629/in+docs
Del: other reasons-- https://master.php.net/note/delete/78629
Reject -- https://master.php.net/note/reject/78629
Search -- https://master.php.net/manage/user-notes.php