服务器端curl请求报错怎么回事?
small团团子2020-11-27 16:34:10
本地正常 同样的代码服务器端就是报错 curl都开启了
后来用file_get_contents试了 在本地可以 但是服务器上也还是不行 这么怎么回事呢?
本地wamp环境 服务器lnmp环境
服务器上别的域名可以 但是小红书的不行
- $url = 'https://www.xiaohongshu.com/discovery/item/5fba8c490000000001005a1e?xhsshare=CopyLink&appuid=5e14b8350000000001006942&apptime=1606308627';
- $header = array(
- 'Accept: application/json',
- 'authority: www.xiaohongshu.com',
- 'User-Agent: Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36',
- 'cookie: xhsTracker=url=noteDetail&xhsshare=CopyLink; xhsTrackerId=da504d27-63f0-4246-c2fa-8159bf20758d; xhsuid=7iLsbVWVyMDgthf4; extra_exp_ids=gif_exp1,ques_clt2; timestamp2=202011191863cb58f25905bcc21fd4bf; timestamp2.sig=qPLANf2J21I-mc_WPaBFp2sPgkGPT4m3itHzsYFTbSI; xhs_spses.5dde=*; noteIndex=3; xhs_spid.5dde=5f41b24bd15581ea.1605059465.3.1605753267.1605585079.c82e763b-4afd-4389-83c4-9dd5bfc5f46b');
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
- $output = curl_exec($ch);
- var_dump($output);
复制代码
|