0

Почему такой код не сохраняет куки?

$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);
0

2 ответа 2

1

Забыл обработать https, поэтому данный скрипт не работает в принципе от слова вообще:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

Документацию смотрите внимательнее.

-1
curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ . "/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ . "/cookies.txt");

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.