douza6300 2012-06-16 07:08 采纳率: 0%
浏览 202
已采纳

如何使用PHP cURL登录Amazon

I need to login to Amazon page: https://sellercentral-japan.amazon.com/gp/sign-in/sign-in.html/ref=pt_login_lgin_login with PHP cURL (without Amazon Web Service).

Here is code how I tried for that:

const AMAZON_LOGIN_URL = "https://sellercentral-japan.amazon.com/gp/sign-in/sign-in.html/ref=pt_login_lgin_login";

$this->crawler = new crawler();        
// login with Amazon account
$parameters ='protocol=https&action=sign-in&email='.self::AMAZON_USER.'&password='.self::AMAZON_PWD;
$status = $this->crawler->logIn(self::AMAZON_LOGIN_URL, $parameters);

/* in crawler class */
//This is used for login.
function logIn($loginActionUrl, $parameters) {
    $strCookie = 'D:\public_html\project\cookie.txt';

    curl_setopt($this->curl, CURLOPT_URL, $loginActionUrl);
    curl_setopt($this->curl, CURLOPT_POST, 1);
    curl_setopt($this->curl, CURLOPT_POSTFIELDS, $parameters);

    curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($this->curl, CURLOPT_HEADER, 0);

    curl_setopt($this->curl, CURLOPT_COOKIEJAR, $strCookie);
    curl_setopt($this->curl, CURLOPT_COOKIEFILE, $strCookie);

    $content = curl_exec($this->curl);
    return $content;
}

As a response, I get login page with error message: "Your login session expired. Please sign in again." And this message is also displayed:

"Not Found

The requested URL /aan/2009-09-09/static/amazon/iframeproxy-12.html was not found on this server."

I have tried most of the solutions found on web. This solution was hopeful but still not working: PHP Curl - Cookies problem I have changed required login page URL and made few other changes but it give this error:

"There was an error trying to perform this operation. Please try again in 15 minutes." even after 15 min, it gives the same error.

If anybody can help, it would be help.

Thanks.

  • 写回答

2条回答 默认 最新

  • dongtu1789 2012-06-16 15:22
    关注

    Just for marking as answer:
    you have to 2 things:

    1. Request login page from server using get method
    2. Send login data using new session and with hidden inputs

    to see the script : https://stackoverflow.com/a/7532730/889678

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能