关闭

不显示删除回复显示所有回复显示星级回复显示得分回复 [推荐] php 模拟GMAIL,HOTMAIL(MSN),YAHOO,163,126邮箱登录

1198人阅读 评论(0) 收藏 举报

 

 

2.HOTMAIL(MSN)

 

 

3.YAHOO

 

 

 

163源码

 

 

 

<?php
define( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) );   //定义COOKIES存放的路径,要有操作的权限
define( "TIMEOUT", 1000 ); //超时设定

class contacts163
{

   
function checklogin( $user, $password )
    {
       
$ch = curl_init( );
        curl_setopt(
$ch, CURLOPT_SSL_VERIFYPEER, false );
        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" );
        curl_setopt(
$ch, CURLOPT_POST, 1 );
        curl_setopt(
$ch, CURLOPT_POSTFIELDS, "username=".$user."&password=".$password."&type=1" );
        curl_setopt(
$ch, CURLOPT_COOKIEJAR, COOKIEJAR );
        curl_setopt(
$ch, CURLOPT_TIMEOUT, TIMEOUT );
       
ob_start( );
        curl_exec(
$ch );
       
$contents = ob_get_contents( );
       
ob_end_clean( );
        curl_close(
$ch );
       
$contents = iconv("UTF-8","GBK",$contents);
       
//die($contents);
        //echo "<textarea>".iconv("UTF-8","GBK",$contents)."</textarea>";
        //echo strip_tags($contents);


       
if ( strpos( $contents, "登录成功" ) !== false )
        {
           
return 1;
        }
       
return 0;
    }

   
function getcontacts( $user, $password, &$result )
    {
       
if ( !$this->checklogin( $user, $password ) )
        {
           
           
return 0;
        }
       
$bRet = $this->_getcookie( $user );
       
$bRet = $this->readcookies( COOKIEJAR, $cookies );
       
$cookieid = substr( trim( $cookies['Coremail'] ), -32 );

       
if ( !$cookieid )
        {
           
return 0;
        }
       
       
$ch = curl_init( );
        curl_setopt(
$ch, CURLOPT_URL, "http://g1a126.mail.163.com/a/s?sid=".$cookieid."&func=global:sequential" );
        curl_setopt(
$ch, CURLOPT_COOKIEFILE, COOKIEJAR );
        curl_setopt(
$ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/xml" ) );
       
$str = "<?xml version=/"1.0/"?><object><array name=/"items/"><object><string name=/"func/">pab:searchContacts</string><object name=/"var/"><array name=/"order/"><object><string name=/"field/">FN</string><boolean name=/"ignoreCase/">true</boolean></object></array></object></object><object><string name=/"func/">user:getSignatures</string></object><object><string name=/"func/">pab:getAllGroups</string></object></array></object>";
        curl_setopt(
$ch, CURLOPT_POST, 1 );
        curl_setopt(
$ch, CURLOPT_POSTFIELDS, $str );
        curl_setopt(
$ch, CURLOPT_TIMEOUT, TIMEOUT );
       
ob_start( );
        curl_exec(
$ch );
       
$contents = ob_get_contents( );
       
ob_end_clean( );
        curl_close(
$ch );
       
$pattern = "/([//w_-])+@([//w])+([//w.]+)/";
       
if ( preg_match_all( $pattern, $contents, $tmpres, PREG_PATTERN_ORDER ) )
        {
           
$result = array_unique( $tmpres[0] );
        }
       
return 1;
    }

   
function _getcookie( $user )
    {
       
$ch = curl_init( );
        curl_setopt(
$ch, CURLOPT_URL, "http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&style=1&username=$user" );
        curl_setopt(
$ch, CURLOPT_COOKIEFILE, COOKIEJAR );
        curl_setopt(
$ch, CURLOPT_COOKIEJAR, COOKIEJAR );
       
ob_start( );
        curl_exec(
$ch );
       
$contents = ob_get_contents( );
       
ob_end_clean( );
        curl_close(
$ch );
    }
   
function readcookies( $file, &$result )
    {
       
$fp = fopen( $file, "r" );
       
while ( !feof( $fp ) )
        {
           
$buffer = fgets( $fp, 4096 );
           
$tmp = split( "/t", $buffer );
           
$result[trim( $tmp[5] )] = trim( $tmp[6] );
        }
       
return 1;
    }

}
$res = array();

$mail163 = new contacts163;

$mail163->getcontacts('aaaaaaa@163.com',123456, &$res);

print_R($res);

?>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3901次
    • 积分:57
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:3篇
    • 译文:0篇
    • 评论:0条
    文章存档