Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [CURL] Logowanie Allegro
hostcom
post
Post #1





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 1.03.2008

Ostrzeżenie: (0%)
-----


Witam
Piszę klasę do logowania allegro i mam następujący problem.
Otóż po przesłaniu wszystkich parametrów wymaganych do logowania występuję po stronie allegro następujący komunikat:
"Ten formularz stracił ważność, wyślij go ponownie."

  1. ?php
  2.  
  3. $login='';
  4. $password='';
  5.  
  6. class Allegro{
  7. public static function curl ($url, $post = NULL, $ref = NULL, $follow = 1, $header = 1, $post_type = NULL)
  8. {
  9. $ch = curl_init ($url);
  10. $headers = array('Accept-Language: pl,en-us;q=0.7,en;q=0.3','Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
  11. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  12. curl_setopt($ch, CURLOPT_ENCODING, 'deflate');
  13. curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7');
  14. curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  15. // Zapisywanie ciastek do pliku
  16. curl_setopt($ch,CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');
  17. curl_setopt($ch,CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
  18. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  19. if ( ! empty($post))
  20. {
  21. $postVars='';
  22. foreach ($post as $option => $value)
  23. $postVars .= $option.'='.urlencode($value).'&';
  24. curl_setopt($ch, CURLOPT_POST, 1);
  25. curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
  26. }
  27. if($ref)
  28. curl_setopt($ch, CURLOPT_REFERER, $ref);
  29. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  30. curl_setopt($ch, CURLOPT_HEADER, 1);
  31. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow);
  32. $r = curl_exec($ch);
  33. curl_close($ch);
  34. return $r;
  35. }
  36.  
  37.  
  38. public function Login($login,$password){
  39. global $URL;
  40.  
  41. $login = $this->curl('http://allegro.pl');
  42. $login = $this->curl('https://ssl.allegro.pl/fnd/authentication/',null,'http://allegro.pl',1);
  43.  
  44. preg_match_all('/\shref="(.+?)"\s/', $login, $rand1);
  45. preg_match_all('/\svalue="(.+?)"\s/', $login, $rand);
  46. echo'<pre>';
  47. print_r($rand);
  48.  
  49.  
  50. $POST=array(
  51. 'userForm[redirectUri]'=>$rand[1][0],
  52. 'userForm[clientId] '=>$rand[1][1],
  53. 'userForm[responseType]'=>$rand[1][2],
  54. 'userForm[scope]'=>$rand[1][3],
  55. 'userForm[state]'=>$rand[1][4],
  56. 'userForm[login]'=>$login,
  57. 'userForm[password]'=>$password,
  58. 'userForm[_token]'=>$rand[1][5]
  59.  
  60. );
  61.  
  62. echo$login = $this->curl('https://ssl.allegro.pl/fnd/authentication/', $POST,'https://ssl.allegro.pl/fnd/authentication/?response_type='.$rand[1][2].'&client_id='.$rand[1][1].'&redirect_uri='.$rand[1][0].'&scope='.$rand[1][3].'&state='.$rand[1][3]);
  63. $login = $this->curl('http://allegro.pl/myaccount/');
  64. if (preg_match('/Wyloguj/',$login))
  65. return true;
  66. }
  67.  
  68.  
  69.  
  70.  
  71. }
  72.  
  73.  
  74.  
  75. ?>


Mógłby ktoś sprawdzić co jest nie tak? ewentulanie przetestować?
Dzieki za pomoc
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 Aktualny czas: 19.08.2025 - 06:50