Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Curl i nowy formularz logowania do google, jw
miras
post 4.05.2017, 19:08:12
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, google zmieniło "formularz" logowania i za nic nie mogę się zalogować przez curla na konto google, na starym formularzu używałem tego kodu:


  1. function getFormFields($data)
  2. {
  3. if (preg_match('/(<form.*?id=.?gaia_loginform.*?<\/form>)/is', $data, $matches)) {
  4. $inputs = getInputs($matches[1]);
  5.  
  6. return $inputs;
  7. } else {
  8. die('didnt find login form');
  9. }
  10. }
  11.  
  12. $ch = curl_init();
  13.  
  14. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  15. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0");
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  17. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  18. curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  20. curl_setopt($ch, CURLOPT_COOKIEJAR, $COOKIEFILE);
  21. curl_setopt($ch, CURLOPT_COOKIEFILE, $COOKIEFILE);
  22. curl_setopt($ch, CURLOPT_HEADER, 0);
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  24. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
  25. curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  26. curl_setopt($ch, CURLOPT_URL,
  27. 'https://accounts.google.com/ServiceLogin?service=youtube&uilel=3&hl=pl&continue=https%3A%2F%2Fwww.youtube.com');
  28. $data = curl_exec($ch);
  29.  
  30.  
  31. $formFields = getFormFields($data);
  32.  
  33.  
  34. $formFields['identifier'] = $USERNAME;
  35. $formFields['password'] = $PASSWORD;
  36. unset($formFields['PersistentCookie']);
  37.  
  38. $post_string = http_build_query($formFields);
  39.  
  40.  
  41. curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/ServiceLoginAuth');
  42. curl_setopt($ch, CURLOPT_POST, 1);
  43. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);


Ma ktoś pomysł jak to rozwiązać?

Ten post edytował miras 4.05.2017, 19:08:44


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 21:09