note 78629 rejected from function.curl-exec by nlopess
| From: | nlopess@php.net | Date: | Fri, 19 Oct 2007 21:15:03 +0000 |
| Subject: | note 78629 rejected from function.curl-exec by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-131575@lists.php.net to get a copy of this message | ||
Note Submitter: mljh at yahoo dot com dot com
----
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!