使用curl / php远程登录亚马逊

时间:2013-05-09 15:46:16

标签: php curl

我自己做了一个使用cURL和PHP登录亚马逊的测试项目,但经过几个小时的圈子,我想我不得不承认失败。我想知道是否有人可以告诉我,我的代码是否出错?

除此之外,我还下载了我的Amazon cookie,并将它们放在与PHP相同的目录中,名为' cookie.txt'

$username ="";      // needs to be changed 
$password = "";     // needs to be changed 

$url = "";          // sign in url  
$cookie = "cookie.txt"; 

$postdata = "email=".$username."&password=".$password; 

$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); 
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
curl_setopt ($ch, CURLOPT_REFERER, $url); 

curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt ($ch, CURLOPT_POST, 1); 
$result = curl_exec ($ch); 

echo $result;  
curl_close($ch);

2 个答案:

答案 0 :(得分:0)

在亚马逊为此提出解决方案之后,您是否还想这样做,请查看 - https://login.amazon.com/

答案 1 :(得分:-1)

此解决方案是否适合您?

PHP Curl - Cookies problem

您可以将登录网址调整为亚马逊的实际登录网址。