命令行中curl某url能获得结果,而php的curl函数却返回不同的结果。
curl http://xxx.xxx.com/refer/?uid=18068937&type=1&limit=10&offset=0
返回code=200,10条正常记录
$ch = curl_init();
$headers = array("Content-Type: application/x-www-form-urlencoded","User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$file_contents = curl_exec($ch);
$aStatus = curl_getinfo($ch);
if(intval($aStatus["http_code"])==200){
return $file_contents;
}else{
return false;
}
却返回"{"code":202,"message":"\u672a\u627e\u5230\u7ed3\u679c"}"
命令行请求和curl程序有什么不同吗? 为什么curl函数返回的和命令行curl的结果不一样呢?