php 類比GMAIL,HOTMAIL(MSN),YAHOO,163,126郵箱登入(原創),該如何處理

來源:互聯網
上載者:User
php 類比GMAIL,HOTMAIL(MSN),YAHOO,163,126郵箱登入(原創)
最近一直在忙,趕在這個十一假期結束的時候,發表一下此文,為了是讓這些源碼開源出來

當然這些方法可能不可取,但大致應該是這種方向了吧,由於目前做的一個UCHOME港台的網站

咱們策劃說要改一下好友邀請裡面的顯示方式,開始我也沒有在意,當時就說行!

到了弄這個的時候才發現,UCH裡面的這個地方是用漫遊型式做的,讓人很是無解,啥都改不了!

唉,既然都答應了說可以,現在實際情況不行了,所以覺得不好意思,為了快速解決這問題,在GOOGLE,

百度上搜了個遍,結果又出忽意料,就一個126郵箱的開源例子,其它的都沒有,有一牛哥留著QQ說要其它的源碼,

可以加QQ買!不對此人評論了!俺花了點時間,整了整,結果就幸運的弄出來了幾個,因為時間有限,目前手上的項目一直在弄,所以就沒有管其它的,現在給出 GMAIL,HOTMAIL(MSN),YAHOO的郵箱連絡人的PHP原始碼:



1.GMAIL
PHP code
 /i', $contents, $matches);                    if(!empty($matches)) {                        $$v = $matches[1];                        $matches = array();                    }                        }                $server = 'mail';                preg_match('//i', $contents, $matches);                if(!empty($matches)) {                    $GALX = $matches[1];                    $matches = array();                }                 $timeStmp = time();                                //第二步: 開始登入                $ch = curl_init();                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginAuth");                curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);                 curl_setopt($ch, CURLOPT_POST, 1);                $fileds = "dsh=$dsh&Email=".$username."&Passwd={$password}&GALX=$GALX&timeStmp=$timeStmp&secTok=$secTok&signIn=Sign in&rmShown=1&asts=&PersistentCookie=yes";                 curl_setopt($ch, CURLOPT_POSTFIELDS, $fileds);                 curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);                              curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                $str = curl_exec($ch);                               curl_close($ch);                     //第三步:check Cookies即也算是個引導頁面                $ch = curl_init("https://www.google.com/accounts/CheckCookie?chtml=LoginDoneHtml");                               curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                curl_setopt($ch,CURLOPT_COOKIEFILE,COOKIEJAR);                curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);                                 curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);                     $str2 = curl_exec($ch);                                 curl_close($ch);                                                                if (strpos($contents, "安全退出") !== false)                {                                                return FALSE;                }                               return TURE;        }                //擷取郵箱通訊錄-地址        public function getAddressList($username, $password)        {                               if (!$this->login($username, $password))                {                        return FALSE;                }                //開始進入類比抓取                $ch = curl_init();                curl_setopt($ch, CURLOPT_URL, "http://mail.google.com/mail/contacts/data/contacts?thumb=true&groups=true&show=ALL&enums=true&psort=Name&max=300&out=js&rf=&jsx=true");  //out=js返回json資料,不設定返回為xml資料                   curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);                /*  對於返回xml資料時需要此設定                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/xml"));                $str = "pab:searchContactsFNtrueuser:getSignaturespab:getAllGroups";                curl_setopt($ch, CURLOPT_POSTFIELDS, $str);                                */                curl_setopt($ch, CURLOPT_POST, 1);                                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);                $contents = curl_exec($ch);                curl_close($ch);                //die($contents);                //get mail list from the page information username && emailaddress                /* 對於返回xml資料時的處理                preg_match_all("/(.*)<\/string>/Umsi",$contents,$mails);                preg_match_all("/(.*)<\/string>/Umsi",$contents,$names);                $users = array();                foreach($names[1] as $k=>$user)                {                    //$user = iconv($user,'utf-8','gb2312');                    $users[$mails[1][$k]] = $user;                }                if (!$users)                {                    return '您的郵箱中尚未有連絡人';                }                  */                 $contents = substr($contents, strlen('while (true); &&&START&&&'),  -strlen('&&&END&&& '));                 return $contents;        }}$gamil = new GMAIL;$res = $gamil->getAddressList('username@163.com','123456');echo $res;?> 
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.