远程登录亚马逊(KDP)

时间:2012-03-08 10:06:26

标签: php curl amazon-web-services

我想自动化KDP(Kindle桌面出版)的摘要。由于他们似乎没有任何电子邮件通知系统(至少没有我知道的),我需要通过curl登录。它让我疯了。我正在使用simplehtmldom来检索其登录网站的隐藏输入值。 cookie是正确的,凭证也是如此。有什么东西我完全不见了吗? $ response总是给我原始登录站点。请考虑以下代码:

function login($url) {
require_once(dirname(__FILE__).'/simplehtmldom/simple_html_dom.php');
$html = file_get_html($url);
$formarr = array();
$form = $html->find('#ap_signin_form',0);

$formarr["email"] = $this->user;
$formarr["password"] = $this->pass;
foreach ($html->find('#ap_signin_form input[type=hidden]') as $i)
$formarr[$i->name] = $i->value;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $form->action );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formarr);
curl_setopt($ch, CURLOPT_USERAGENT, $this->agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_AUTOREFERER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false );    # required for https urls

$response = curl_exec($ch);
return $response;
}

0 个答案:

没有答案
相关问题