分享一个curl模拟网易163邮箱登录实例
程序员文章站
2022-06-14 17:06:51
...
分享一个curl模拟网易163邮箱登录实例
分享一个curl模拟网易163邮箱登录实例,需要的朋友可以参考一下,代码如下所示:
php curl模拟yahoo邮箱登录代码实例http://www.jb100.net/html/content-22-384-1.html
分享一个curl模拟网易163邮箱登录实例,需要的朋友可以参考一下,代码如下所示:
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 "";
//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 = "";
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);
?>
php curl模拟GMAIL邮箱登录代码实例http://www.jb100.net/html/content-22-388-1.htmlphp curl模拟yahoo邮箱登录代码实例http://www.jb100.net/html/content-22-384-1.html
AD:真正免费,域名+虚机+企业邮箱=0元