【发布时间】:2013-02-16 01:59:34
【问题描述】:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
var_dump($output);
$json_array = json_decode($output, true);
var_dump(curl_error($ch));
curl_close($ch);
var_dump($json_array);
$output 的 VARDUMP
string(267) "HTTP/1.1 200 OK 日期:2013 年 3 月 1 日星期五 14:16:57 GMT 服务器:Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 X-Powered- By: PHP/5.4.7 缓存控制: no-cache x-debug-token: 5130b85a178bd 传输编码: 分块内容类型: application/json {"name":"manoj"}"
curl_error($ch) 的 VARDUMP
字符串(0) ""
$json_array 的 VARDUMP
空
【问题讨论】:
-
您的输出是所有带有标题的内容,尽管它不是有效的 JSON。