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."
?php
$login='';
$password='';
class Allegro{
public static function curl
($url, $post = NULL, $ref = NULL, $follow = 1
, $header = 1
, $post_type = NULL) {
$ch = curl_init ($url);
$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'); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, 'deflate');
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');
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
// Zapisywanie ciastek do pliku
curl_setopt
($ch,CURLOPT_COOKIEJAR
, dirname(__FILE__).'/cookie.txt');curl_setopt
($ch,CURLOPT_COOKIEFILE
, dirname(__FILE__).'/cookie.txt');curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
{
$postVars='';
foreach ($post as $option => $value)
$postVars .= $option.'='.urlencode($value).'&'; curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
}
if($ref)
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow);
$r = curl_exec($ch);
curl_close($ch);
return $r;
}
public function Login($login,$password){
$login = $this->curl('http://allegro.pl');
$login = $this->curl('https://ssl.allegro.pl/fnd/authentication/',null,'http://allegro.pl',1);
'userForm[redirectUri]'=>$rand[1][0],
'userForm[clientId] '=>$rand[1][1],
'userForm[responseType]'=>$rand[1][2],
'userForm[scope]'=>$rand[1][3],
'userForm[state]'=>$rand[1][4],
'userForm[login]'=>$login,
'userForm[password]'=>$password,
'userForm[_token]'=>$rand[1][5]
);
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
]); $login = $this->curl('http://allegro.pl/myaccount/');
return true;
}
}
?>
Mógłby ktoś sprawdzić co jest nie tak? ewentulanie przetestować?
Dzieki za pomoc