Witam, próbuję stworzyć automatyczne logowania w cUrl, zrobiłem już kilka takich systemów na rożnych portalach, ale teraz męczę się od kilku dni nad automatycznym logowaniem na stronie:
https://twojrachunek.pl/TwojRachunek/Mam gotowy skrypt, wszystkie zmienne wypisane, a secureCode odczytuje się automatycznie, a mimo tego nie jestem w stanie się zalogować i wyświetlić zawartości strony.
Czy ktoś ma jakiś pomysł? Z góry dzięki za sugestie:
$url = "https://twojrachunek.pl/TwojRachunek/index.html";
$ckfile = tempnam("/tmp", "CURLCOOKIE");
$username = "xxxxxxxx";
$password = "xxxxxxxx";
$f = fopen('log.txt', 'w'); // file to write request header for debug purpose
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
curl_close($ch);
list
($a, $b) = explode("<input type='hidden' name='secure_text' value=", $html);//$a = str_replace("'", "", $a);
$secure = $a;
/**
Start Login process
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"user=$username&password=$password&path=loginservlet&secure_text=$secure");
$ret = curl_exec($ch); // Get result after login page.
Ten post edytował Peter30 26.09.2015, 14:19:31