php類比登陸163郵箱失敗,求解

來源:互聯網
上載者:User
   

//目前本人技術只能做到這裡,,無法類比成功登陸,
//上面的郵箱可以使用,,求好心人幫忙解決。。


回複討論(解決方案)

參考:

 $user,            'password'      => $pass,            'verifycookie'  => 1,            'style'         => -1,            'product'       => 'mail163',            'selType'       => -1,            'secure'        => 'on'        );         $fields_string = '';            foreach($fields_post as $key => $value){            $fields_string .= $key . '=' . $value . '&';        }            $fields_string = rtrim($fields_string , '&');        $headers = array(            'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0',            'Referer'    => 'http://www.163.com'        );        $ch = curl_init($url);          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//返回結果存放在變數中,而不是預設的直接輸出        curl_setopt($ch, CURLOPT_HEADER, true);        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);//關閉串連時,將伺服器端返回的cookie儲存在以下檔案中         curl_setopt($ch, CURLOPT_POST, true);        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);               $result= curl_exec($ch);        curl_close($ch);        preg_match_all('/(.*?) <\/div>/i', $result,$infos,PREG_SET_ORDER);        if(!empty($infos['0']['1'])){            unlink($cookie);            exit('');        }else{                  $G_ROOT = dirname(__FILE__);            file_put_contents($G_ROOT.'/cache/cookie', $cookie);            return $cookie;        }    }    /**     *      * $data['url'] 請求地址     * $data['data_post'] post資料     * $data['cookie']     *    **/    function curl($data){        $url = $data['url'];        $data_post= $data['data_post']? $data['data_post']: false;        $cookie = $data['cookie'];              $headers = array(            'User-Agent'        => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0',            'Referer'    => 'http://www.163.com'        );        $ch = curl_init($url);           curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        curl_setopt($ch, CURLOPT_HEADER, true);        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);              curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);  //cookie檔案 登陸之後         //POST 提交        if($data_post){            curl_setopt($ch, CURLOPT_POST, 1);            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_post);        }        $result = curl_exec($ch);        curl_close($ch);        return $result;    }
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.