国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php - curl 模擬找回密碼出現(xiàn)不能理解的錯誤
大家講道理
大家講道理 2017-04-11 09:47:12
0
1
507

curl模擬找回密碼(華夏保險)直接找回密碼頁面 http://www.ihxlife.com/forget...
輸入手機號15677748704(測試)獲取驗證碼 直接會提示驗證碼錯誤

但先進入官網(wǎng)后通過官網(wǎng)鏈接進入頁面能獲取驗證碼

通過代碼實現(xiàn) 先訪問主頁面獲取cookie 再利用獲取的cookie訪問找回密碼頁面更新cookie
然后獲取驗證碼 ——————失敗 短信驗證碼發(fā)送失敗

 public function forgetPwdIndex(){
        $uKey = 'HuaXia' . date("YmdHis") . uniqid();
        $cookieVerify = APP_COOKIE . "/" . $uKey . ".tmp";
        $url = 'http://www.ihxlife.com/';//登錄主頁的url來獲取cookie
        $this->getCookie($url, $cookieVerify);//獲取到登錄頁面的cookie
        //獲取找回密碼頁的cookie
        $pwdUrl='http://www.ihxlife.com/forget/forgetPwd';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $pwdUrl);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_TIMEOUT, 120); // 設(shè)置超時限制防止死循環(huán)
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding:gzip, deflate',
            'Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
            'Connection:keep-alive',
            'Host:www.ihxlife.com'));
        curl_setopt($ch, CURLOPT_REFERER,'http://www.ihxlife.com/');
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieVerify);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieVerify);
        curl_exec($ch);
        curl_close($ch);
        //echo $cookieVerify."<br>";
        $this->assign('key', $uKey);//傳到頁面中 在頁面中post該數(shù)據(jù) 拼組cookie文件
        $this->display();
    }
    
    public function sendPwdMobileCode(){
    if(I('post.key')==''||I('post.mobile')==''){
        echo json_encode(array('status'=>'10001','message'=>'參數(shù)錯誤'));
        die;
    }
    $requireUrl='http://www.ihxlife.com/sms/smsCode_Send';//請求地址
    $postData='mobile='.I('post.mobile').'&busiType=10019&effectiveTime=180';
    $cookieVerify = APP_COOKIE . "/" . I('post.key') . ".tmp";
    echo $cookieVerify."<br>";
    $referer='http://www.ihxlife.com/forget/forgetPwd';
    echo $this->curlPost($requireUrl,$postData,$cookieVerify,$referer,30,true);
}
    
       public function getCookie($url, $cookieVerify)
    {
        echo $cookieVerify."<br>";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding:gzip, deflate',
'Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Connection:keep-alive',
'Host:www.ihxlife.com'));
        curl_setopt($ch, CURLOPT_TIMEOUT, 120); // 設(shè)置超時限制防止死循環(huán)
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieVerify);
        curl_exec($ch);
        curl_close($ch);
    }
    
    
 

public function curlPost($url, $post_fields, $cookieVerify, $referer = '', $timeOut = 30, $header = '')
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0');
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    if ($referer) {
        curl_setopt($curl, CURLOPT_REFERER, $referer);
    } else {
        curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
    }
    if ($header) {
        //curl_setopt($curl, CURLOPT_HTTPHEADER, array('Host:www.ihxlife.com', 'X-Requested-With:XMLHttpRequest'));
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding:gzip, deflate',
            'Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
            'Content-Type:application/x-www-form-urlencoded; charset=UTF-8',
            'Connection:keep-alive',
            'Host:www.ihxlife.com',
            'X-Requested-With:XMLHttpRequest'));
    }
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_COOKIEFILE, $cookieVerify);
    curl_setopt($curl, CURLOPT_COOKIEJAR, $cookieVerify);
    curl_setopt($curl, CURLOPT_TIMEOUT, $timeOut);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $resultData = curl_exec($curl); // 執(zhí)行操作
    curl_close($curl);
    return $resultData;
}
大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(1)
左手右手慢動作

問題解決了。這個網(wǎng)站在加載主頁登錄模塊的驗證碼時更新了cookie。我之前的思路一直在要加載頁面要加載頁面 然后沒有注意到這里 只要再訪問下主頁驗證碼保存更新的驗證碼就好!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template