Why doesn’t CURL authorize on https://kabinet_dot_3ton_dot_eu ?

such a function

 function login($url,$login,$pass){ $ch = curl_init(); if(strtolower((substr($url,0,5))=='https')) { // если соединяемся с https 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,"wizard[username]=".$login."&wizard[password]=".$pass); 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"); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //сохранять полученные COOKIE в файл curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt'); $result=curl_exec($ch); // Убеждаемся что произошло перенаправление после авторизации if(strpos($result,"Location: gsm-platby-sim.html")===false) die('Login incorrect'); curl_close($ch); return $result; } $url="https___centrum_dot_3ton_dot_eu"; $login="asd"; $pass="asd"; echo login($url,$login,$pass); 

Instead of letters in the password you need to substitute the numbers

I must say that the code can not be changed on the site.

  • And curl_error($ch); what returns? - cyadvert
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Here I have succeeded, use the ready-made solution)))

 <?php function login($url,$login,$pass){ $ch = curl_init(); if(strtolower((substr($url,0,5))=='https')) { // если соединяемся с https 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, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,"odeslano=true&wizard[username]=".$login."&wizard[password]=".$pass); 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"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); //сохранять полученные COOKIE в файл curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie_kabinet.3ton.eu.txt'); $result=curl_exec($ch); // Убеждаемся что произошло перенаправление после авторизации if(strpos($result,"Location: ./main-page.html")===false) die('Login incorrect'); curl_close($ch); return $result; } $url="https://kabinet.3ton.eu/uvod"; $login="asd"; $pass="asd"; echo login($url,$login,$pass); 
  • one
    Thank you very much, everything ran. kapets. Can you describe the sequence of actions a little, at least a little? I think it will be useful to others. - Alex