【发布时间】:2014-01-26 21:14:14
【问题描述】:
我正在使用 cuRL 从远程服务器获取一些数据...响应是 JSON 格式.. 这是我的代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, 'http://www.myaddress.com/mypage.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, array("id" => $id));
$return = curl_exec($ch);
curl_close($ch);
如果我在浏览器中访问该链接,页面加载正常,但如果我通过 cuRL 访问返回 404 错误...
【问题讨论】:
-
你能先检查被调用页面的标题,以验证你是否有代码 200 或其他内容吗?
-
另外,你检查过这篇文章吗:stackoverflow.com/questions/17476828/…
-
curl_getinfo在http_code中返回404
-
同一个url,here得到什么http状态?
-
该 URL 是否可访问?如果有,可以在这里分享一下吗?