3

我需要使用 PHP cURL(没有 Amazon Web Service)登录到亚马逊页面: https ://sellercentral-japan.amazon.com/gp/sign-in/sign-in.html/ref=pt_login_lgin_login。

这是我如何尝试的代码:

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;
}

作为响应,我收到带有错误消息的登录页面:“您的登录会话已过期。请重新登录。” 并且还会显示此消息:

“未找到

在此服务器上找不到请求的 URL /aan/2009-09-09/static/amazon/iframeproxy-12.html。”

我已经尝试了大多数在网上找到的解决方案。这个解决方案很有希望,但仍然不起作用: PHP Curl - Cookies 问题 我已经更改了所需的登录页面 URL 并进行了一些其他更改,但它给出了这个错误:

“尝试执行此操作时出错。请在 15 分钟后重试。” 即使在 15 分钟后,它也会给出相同的错误。

如果有人可以提供帮助,那将是有帮助的。

谢谢。

4

2 回答 2

4

只是为了标记为答案:
你必须做两件事:

  1. 使用 get 方法从服务器请求登录页面
  2. 使用新会话和隐藏输入发送登录数据

查看脚本:https ://stackoverflow.com/a/7532730/889678

于 2012-06-16T15:22:46.973 回答
-1

使用他们的官方 Curl API... 在这里查看 php 示例http://login.amazon.com/website

于 2014-06-25T04:18:48.647 回答