<code>header('Content-type: text/html; charset=utf-8');
require 'phpQuery/phpQuery.php';
function debug($arr) {
echo '<pre>'. print_r($arr, true). '
';} function getContent ($ url, $ data = []) {$ ch = curl_init ($ url);curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true);curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true);curl_setopt ($ ch, CURLOPT_POST, true);curl_setopt ($ ch, CURLOPT_POSTFIELDS, http_build_query ($ data));curl_setopt ($ ch, CURLOPT_COOKIEJAR, __DIR__. '/cookie.txt');curl_setopt ($ ch, CURLOPT_COOKIEFILE, __DIR__. '/cookie.txt');$ res = curl_exec ($ ch);curl_close ($ ч);вернуть $ res;} $ urlAuth = '
https://auth.mail.ru/cgi-bin/auth'; $ url ='
https://wf.mail.ru/officers'; $ auth_data = ['Page' => '
https://wf.mail.ru/',' FakeAuthPage '=>'
https://wf.mail.ru/auth', 'Login' => 'MyNail', 'Password' => 'MyPass', 'do_login' => ''];$ data = getContent ($ urlAuth, $ auth_data);$ data = getContent ($ url);отладки ($ данных);
В cookie-файле данные пишутся нормально, но при переходе на страницу wf.mail.ru/officers содержимое не отображается.Подскажите в чем ошибка.Спасибо.
Добавлена ошибка вывода, ошибка: пустой ответ с сервера.Но почему ответ пуст?
Я добавил в getContent ()
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)');
if (!empty($data))
curl_setopt($ch, CURLOPT_POST, true);
else
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_FAILONERROR, true);