为什么这段代码不保存 cookie?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ocservice.taobao.com/cookieController/processUserCookie?site=CN_zh-CN_CNY_156&callback=jsonp_1546706091271_92560');
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
$http_headers = array(
'Host: www.google.ca',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2',
'Accept: */*',
'Accept-Language: en-us,en;q=0.5',
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Connection: keep-alive'
);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
我忘了处理 https,所以这个脚本在原则上根本不起作用:
更仔细地查看文档。