php curl 在linux下可以获得数据,转换成php就不行了

vbphp爱好者 发布于 2016/04/25 22:03
阅读 772
收藏 0

MySQL连接为什么挂死了?别踩坑!>>>

刚学curl,用firebug获得网站的curl命令,在linux下拷贝过去可以直接获得json数据,把从firebug的curl转换成php的就获得不了,不知道还缺什么设置

php curl code:
header("content-Type: text/html; charset=UTF-8");
$ch = curl_init();
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0');
curl_setopt($ch, CURLOPT_URL, "http://www.meidebi.com/Ajax/showdan_active");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//设置返回数据
$refer      = 'http://www.meidebi.com/index_n/';    //来路地址
   curl_setopt($ch, CURLOPT_REFERER, $refer);    //来路模拟

curl_setopt($ch, CURLOPT_HEADER, 0);//设置头部不执行
curl_setopt($ch,CURLOPT_COOKIE,'PHPSESSID=f8qgv7le5f2qh9gkajvv2cf4i5; dss=cc; bfdtoken=840001747a0181285ede8f93d5129969; Hm_lvt_8eee4cacb173e36099ceadd434aa2376=1461588295; Hm_lpvt_8eee4cacb173e36099ceadd434aa2376=1461592266; bfd_s=20006308.34405393.1461588295578; tmc=22.20006308.90127145.1461588295580.1461591421924.1461591422917; tma=20006308.90127145.1461588295580.1461588295580.1461588295580.1; tmd=22.20006308.90127145.1461588295580.; bfd_g=bffd842b2b48433200002a510000cd4056d83cda; amvid=63838e4cf452dc1d75f3cae63a407ac3; user_region_id=think%3A%7B%22parent_id%22%3A%2211%22%2C%22region_id%22%3A%22109%22%7D; think_language=zh-CN');  
$output = curl_exec($ch);//执行
curl_close($ch);//释放curl句柄
var_dump($output);

linux curl:
curl 'http://www.meidebi.com/Ajax/showdan_active' -H 'Host: www.meidebi.com' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3' -H 'DontTrackMeHere: gzip, deflate' -H 'X-Requested-With: XMLHttpRequest' -H 'Referer: http://www.meidebi.com/index_n/' -H 'Cookie: PHPSESSID=f8qgv7le5f2qh9gkajvv2cf4i5; dss=cc; bfdtoken=840001747a0181285ede8f93d5129969; Hm_lvt_8eee4cacb173e36099ceadd434aa2376=1461588295; Hm_lpvt_8eee4cacb173e36099ceadd434aa2376=1461592266; bfd_s=20006308.34405393.1461588295578; tmc=22.20006308.90127145.1461588295580.1461591421924.1461591422917; tma=20006308.90127145.1461588295580.1461588295580.1461588295580.1; tmd=22.20006308.90127145.1461588295580.; bfd_g=bffd842b2b48433200002a510000cd4056d83cda; amvid=63838e4cf452dc1d75f3cae63a407ac3; user_region_id=think%3A%7B%22parent_id%22%3A%2211%22%2C%22region_id%22%3A%22109%22%7D; think_language=zh-CN'

加载中
0
v
vbphp爱好者
自己加了 CURLOPT_HTTPHEADER 可以获取了
返回顶部
顶部