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:

  1. $url = "https://twojrachunek.pl/TwojRachunek/index.html";
  2. $ckfile = tempnam("/tmp", "CURLCOOKIE");
  3.  
  4. $username = "xxxxxxxx";
  5. $password = "xxxxxxxx";
  6.  
  7.  
  8. $f = fopen('log.txt', 'w'); // file to write request header for debug purpose
  9.  
  10. $ch = curl_init($url);
  11. curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
  12. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14.  
  15.  
  16. $html = curl_exec($ch);
  17.  
  18. curl_close($ch);
  19. list($a, $b) = explode("<input type='hidden' name='secure_text' value=", $html);
  20. list($a, $b) = explode(">", $b);
  21. //$a = str_replace("'", "", $a);
  22. $secure = $a;
  23.  
  24.  
  25.  
  26. /**
  27.  Start Login process
  28.  */
  29. $ch = curl_init();
  30.  
  31. curl_setopt($ch, CURLOPT_URL, $url);
  32. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
  34. curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
  35. curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
  36. curl_setopt($ch, CURLOPT_HEADER, FALSE);
  37. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  38. curl_setopt($ch, CURLOPT_REFERER, $url);
  39.  
  40. curl_setopt($ch, CURLOPT_POST, 1);
  41. curl_setopt($ch, CURLOPT_POSTFIELDS,"user=$username&password=$password&path=loginservlet&secure_text=$secure");
  42. $ret = curl_exec($ch); // Get result after login page.
  43.  
  44. print $ret;
  45.