Rumah > php教程 > php手册 > 分享一个curl模拟网易163邮箱登录实例

分享一个curl模拟网易163邮箱登录实例

WBOY
Lepaskan: 2016-06-07 11:40:37
asal
1933 orang telah melayarinya

分享一个curl模拟网易163邮箱登录实例
分享一个curl模拟网易163邮箱登录实例,需要的朋友可以参考一下,代码如下所示:<?php <br /> define( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) );   //定义COOKIES存放的路径,要有操作的权限<br> define( "TIMEOUT", 1000 ); //超时设定<br> <br> class contacts163<br> {<br> <br> function checklogin( $user, $password )<br> {<br> $ch = curl_init( );<br> curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );<br> curl_setopt( $ch, CURLOPT_URL, "http://reg.163.com/logins.jsp?type=1&product=mail163&url=http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight%3D1%26verifycookie%3D1%26language%3D-1%26style%3D1" );<br> curl_setopt( $ch, CURLOPT_POST, 1 );<br> curl_setopt( $ch, CURLOPT_POSTFIELDS, "username=".$user."&password=".$password."&type=1" );<br> curl_setopt( $ch, CURLOPT_COOKIEJAR, COOKIEJAR );<br> curl_setopt( $ch, CURLOPT_TIMEOUT, TIMEOUT );<br> ob_start( );<br> curl_exec( $ch );<br> $contents = ob_get_contents( );<br> ob_end_clean( );<br> curl_close( $ch );<br> $contents = iconv("UTF-8","GBK",$contents);<br> //die($contents);<br> //echo "<textarea>".iconv("UTF-8","GBK",$contents)."</textarea>";<br> //echo strip_tags($contents);<br> <br> if ( strpos( $contents, "登录成功" ) !== false )<br> {<br> return 1;<br> }<br> return 0;<br> }<br> <br> function getcontacts( $user, $password, &$result )<br> {<br> if ( !$this->checklogin( $user, $password ) )<br> {<br> <br> return 0;<br> }<br> $bRet = $this->_getcookie( $user );<br> $bRet = $this->readcookies( COOKIEJAR, $cookies );<br> $cookieid = substr( trim( $cookies['Coremail'] ), -32 );<br> <br> if ( !$cookieid )<br> {<br> return 0;<br> }<br> <br> $ch = curl_init( );<br> curl_setopt( $ch, CURLOPT_URL, "http://g1a126.mail.163.com/a/s?sid=".$cookieid."&func=global:sequential" );<br> curl_setopt( $ch, CURLOPT_COOKIEFILE, COOKIEJAR );<br> curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/xml" ) );<br> $str = "<?xml version=\"1.0\"?><object><array><object><string>pab:searchContacts</string><object><array><object><string>FN</string><boolean>true</boolean></object></array></object></object><object><string>user:getSignatures</string></object><object><string>pab:getAllGroups</string></object></array></object>";<br> curl_setopt( $ch, CURLOPT_POST, 1 );<br> curl_setopt( $ch, CURLOPT_POSTFIELDS, $str );<br> curl_setopt( $ch, CURLOPT_TIMEOUT, TIMEOUT );<br> ob_start( );<br> curl_exec( $ch );<br> $contents = ob_get_contents( );<br> ob_end_clean( );<br> curl_close( $ch );<br> $pattern = "/([\\w_-])+@([\\w])+([\\w.]+)/";<br> if ( preg_match_all( $pattern, $contents, $tmpres, PREG_PATTERN_ORDER ) )<br> {<br> $result = array_unique( $tmpres[0] );<br> }<br> return 1;<br> }<br> <br> function _getcookie( $user )<br> {<br> $ch = curl_init( );<br> curl_setopt( $ch, CURLOPT_URL, "http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&style=1&username=$user" );<br> curl_setopt( $ch, CURLOPT_COOKIEFILE, COOKIEJAR );<br> curl_setopt( $ch, CURLOPT_COOKIEJAR, COOKIEJAR );<br> ob_start( );<br> curl_exec( $ch );<br> $contents = ob_get_contents( );<br> ob_end_clean( );<br> curl_close( $ch );<br> }<br> function readcookies( $file, &$result )<br> {<br> $fp = fopen( $file, "r" );<br> while ( !feof( $fp ) )<br> {<br> $buffer = fgets( $fp, 4096 );<br> $tmp = split( "\t", $buffer );<br> $result[trim( $tmp[5] )] = trim( $tmp[6] );<br> }<br> return 1;<br> }<br> <br> }<br> $res = array();<br> <br> $mail163 = new contacts163;<br> <br> $mail163->getcontacts('aaaaaaa@163.com',123456, &$res);<br> <br> print_R($res);<br> <br> ?>php curl模拟GMAIL邮箱登录代码实例http://www.jb100.net/html/content-22-388-1.html
php curl模拟yahoo邮箱登录代码实例http://www.jb100.net/html/content-22-384-1.html

AD:真正免费,域名+虚机+企业邮箱=0元

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan