使用curl PHP登录AOL邮件

时间:2012-09-24 16:24:21

标签: php curl

我做了很长时间的研究,但结果并不好,它总是让我回到登录页面。我设置了post params,header,proxy ....

我使用FireFox的Live HTTP Headers插件来查看POST内容包含的内容,然后将其设置为我的代码,但它仍然不起作用。这是我的代码:

function show($content)
{
    echo "<textarea>$content</textarea>";
}
function aol($mail,$pass, $_sock){
    $url="http://mail.aol.com";     
    $ch = curl_init();      
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
    curl_setopt($ch, CURLOPT_PROXY, $_sock);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

    $content=curl_exec ($ch);
    $this->show($content);
    //Get SNS_SC
    $SNS_SC=explode('SNS_SC=', $content);
    $SNS_SC=explode(';', $SNS_SC[1]);
    $SNS_SC=$SNS_SC[0];     
    //  //Get Site State
    $siteState=explode('siteState" value="', $content);
    $siteState=explode('"', $siteState[1]);
    $siteState=$siteState[0];

    //Get usrd
    $usrd=explode('usrd" value="', $content);
    $usrd=explode('"', $usrd[1]);
    $usrd=$usrd[0];

    $url="https://my.screenname.aol.com/_cqr/login/login.psp";
    $post="sitedomain=sns.webmail.aol.com&siteId=&lang=en&locale=us&authLev=0&siteState=$siteState&isSiteStateEncoded=true&mcState=initialized&uitype=std&use_aam=0&offerId=newmail-en-us-v2&seamless=novl&regPromoCode=&usrd=$usrd&doSSL=&redirType=&xchk=false&tab=&lsoDP=&loginId=$mail&password=$pass";
    //ref
    $ref="https://my.screenname.aol.com/_cqr/login/login.psp?sitedomain=sns.webmail.aol.com&lang=en&seamless=novl&offerId=newmail-en-us-v2&authLev=0&siteState=$siteState&locale=us";


    //

    $arr[] = "Host: my.screenname.aol.com";
    $arr[] = "User-Agent: Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1";
    $arr[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    $arr[] = "Accept-Language: en-us,en;q=0.5";
    $arr[]="Accept-Encoding: gzip, deflate";
    $arr[]="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $arr[] = "Keep-Alive: 300";
    $arr[] = "Connection: keep-alive";
    $arr[] = "Referer: ".$ref;
    $arr[] = "Cookie: SNS_SC=" . $SNS_SC ;
    $arr[] = "Content-Type: application/x-www-form-urlencoded";
    $arr[] = "Content-Length: " . strlen($post);
    //$arr[] = $post;
    //
    curl_setopt($ch, CURLOPT_HEADER, $arr);
    curl_setopt($ch, CURLOPT_POST ,1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);       
    curl_setopt($ch, CURLOPT_URL, $url);                
    curl_setopt($ch, CURLOPT_REFERER, $ref);        

    $result=curl_exec ($ch);

    curl_close ($ch);
    //$this->show($result);
    echo $result;       
    return 0;
}

有什么想法吗?谢谢:))

0 个答案:

没有答案