Good evening.
Could not be authenticated using cURL. It seems to be doing everything right, but still does not allow.
Here is the site - http://www.vezetvsem.ru/listing Here is the authorization form - https://auth.vezetvsem.ru/auth/login
There are no hidden fields. Login / password are correct. For the test, you can use these: Login: 6kp5228wi4@kismail.ru Pass: w33q5u8t
After testing the code, we get the code from the unauthorized page.
<? function login($url,$login,$pass){ $ch = curl_init(); if(strtolower((substr($url,0,5))=='https')) { // если соединяемся с https //моя вставка curl_setopt($ch, CURLOPT_COOKIESESSION, true); //моя вставка curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); } curl_setopt($ch, CURLOPT_URL, $url); // откуда пришли на эту страницу curl_setopt($ch, CURLOPT_REFERER, $url); // cURL будет выводить подробные сообщения о всех производимых действиях curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,"username=".$login."&password=".$pass); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); echo "username=".$login."&password=".$pass; //сохранять полученные COOKIE в файл curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt'); $result=curl_exec($ch); // Убеждаемся что произошло перенаправление после авторизации if(strpos($result,"Location: home.php")===false) die('Login incorrect'); curl_close($ch); return $result; } // чтение страницы после авторизации function Read($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_COOKIESESSION, true); // откуда пришли на эту страницу curl_setopt($ch, CURLOPT_REFERER, $url); //запрещаем делать запрос с помощью POST и соответственно разрешаем с помощью GET curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //отсылаем серверу COOKIE полученные от него при авторизации curl_setopt($ch, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (Windows; U; Windows NT 5.0; En; rv:1.8.0.2) Gecko/20070306 Firefox/1.0.0.4"); $result = curl_exec($ch); curl_close($ch); return $result; } $urlAut = "https://auth.vezetvsem.ru/auth/login"; login($urlAut,"6kp5228wi4@kismail.ru","w33q5u8t"); $page = Read("http://www.vezetvsem.ru/listing"); echo $page; ?>
if(strpos($result,"Location: home.php")===false) die('Login incorrect');- Vayas