我一直在尝试使用 curl 登录 barnesandnoble.com 移动网站,但到目前为止还没有运气。我返回没有错误的页面,它再次将我的电子邮件默认到登录页面的电子邮件输入表单框中(以 print $result 返回的表单)。
通过将 LOGINURL 更改为指向 ebay 的登录名,相同的代码实际上可以让我正确进入 ebay
唯一的区别是 barnesandnobles 是 https:// 而 ebay 登录是 http://
另外,我相信 barnes 网站是 asp/aspx,所以我不知道如何以不同方式处理 cookie 和 _state
任何帮助将不胜感激,因为我在过去 16 小时内一直在尝试调试它
另外,我的 cookie.txt 是可写的并且可以工作
<?php
$cookie_file_path = "C:/test/cookie.txt";
$LOGINURL = "https://cart2.barnesandnoble.com/mobileacct/op.asp?stage=signIn";
$agent = "Nokia-Communicator-WWW-Browser/2.0 (Geos 3.0 Nokia-9000i)";
$ch = curl_init();
$headers[] = "Accept: */*";
$headers[] = "Connection: Keep-Alive";
$headers[] = "Content-type: application/x-www-form-urlencoded;charset=UTF-8";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$content = curl_exec($ch);
curl_close($ch);
unset($ch);
// NAME="path_state" value="6657403">
if(stristr($content,"path_state")){
$array1 = explode('path_state" value="',$content);
$content1 = $array1[1];
$array2 = explode('">',$content1);
$content2 = $array2[0];
}
$LOGINURL = "https://cart2.barnesandnoble.com/mobileacct/op.asp?stage=signIn";
$POSTFIELDS = "d_hidPageStamp=V_3_17&hidViewMode=opSignIn&stage=signIn&previousStage=mainStage&path_state=" . $content2 . "&emailAddress=YOUREMAILHERE@gmail.com&acctPassword=YOURPASSWORD";
$reffer = "https://cart2.barnesandnoble.com/mobileacct/op.asp?stage=signIn";
$ch = curl_init();
$headers[] = "Accept: */*";
$headers[] = "Connection: Keep-Alive";
$headers[] = "Content-type: application/x-www-form-urlencoded;charset=UTF-8";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec($ch);
print $result;
?>