求一份PHP获取136,126,sina,soho,tom,gmail等各大常用邮箱联系人功能 求一份PHP获取136,126,sina,soho,tom,gmail等各大常用邮箱联系人功能的源码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好多年前,当开心网正火的时候,搞过这东西,一下子忘记了。也懒得google 了,陪你一起坐等答案。 百度了一下,都是curl去抓的,自己试试吧。 灰常感谢现在还有sina,yahoo,sohu的没搞定,我想这些先能跑通,然后整合到thinkphp里面去 终于忙完了,才来论坛,回复晚见谅。待我注册几个号跟踪一下http流程,刚把sohu的注册测试好。例子都是直接可以用的,账号都是真实的,刚注册的。Sohu<?phpdefine( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) ); class sohu{ public function getAddressList($username, $password) { $name=explode('@', $username); $username=$name[0]; $ch = curl_init(); $encodeurl = "http://passport.sohu.com/sso/login.jsp?userid=".urlencode($username . "@sohu.com") . "&password=".md5($password)."&appid=1000&persistentcookie=0&s=".time()."343&b=2&w=1024&pwdtype=1"; curl_setopt($ch, CURLOPT_URL, $encodeurl); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR ); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $contents = curl_exec( $ch ); if ( strpos( $contents, "success" ) === false ) { return 0; } curl_setopt($ch, CURLOPT_URL, "http://mail.sohu.com/bapp/128/main#addressList"); $contents = curl_exec($ch); if(false == $contents){ curl_close( $ch ); return false; }else{ curl_close( $ch ); return $this->parserContent($contents); } } function parserContent($content){ preg_match_all("/var addresses = '(.*)';/Umsi",$content,$data); $numList= json_decode( $data[1][0]); $contactList = array(); foreach ($numList->contact as $val){ $obj = new stdClass; $obj->name = $val->nickname; $obj->nickname = $val->pinyin; $obj->emailAddress = $val->email; if($obj->nickname==""){ $obj->nickname = $obj->name; } $contactList[] = $obj; } if( count($contactList) == 0 ){ return false; }else{ return $contactList; } }}$test = new sohu();$contects = $test->getAddressList('[email protected]', '123456');var_dump($contects);?> 从一个使用者的角度来说, 如果不是用oauth的, 我是不会用这种自动获取联系人的东西的.... http://mail.sohu.com/bapp/128/main#addressList128应该是不同用户不同获取的值,那个测试账号是128,你的可能不是。建议楼主还是不要这种功能了吧,因为人家网站只要改版,写的接口就都白写了,还得重新模拟抓取。无奈国内没有提供api来调用,建议楼主把国内的都去掉吧,国外的比如gmail、、hotmail都有提供api来直接获取联系人的。 最近hotmail的改版引起的直接结果是之前搞的邮箱联系人功能失效,还没找到更好的解决方案,悲催~~~ php 去掉字符串重复的值.??? php中的strpos没有返回值 php开发工具PDT的配置! 怎样取得前一页面的RUL? 请问,查询大量数据放在表格中显示出来时怎么减少显示时间?谢谢! 急问: 数组问题 菜鸟问题:我得不到提交参数的值! 请问各位老大一个性能问题 - 100分必散 在线等待,我的PHP运行不起来了。困惑!!! 有两个问题请教?希望能得到帮助! 一些站长工具是用什么开发的 新人求助:开发环境
例子都是直接可以用的,账号都是真实的,刚注册的。
Sohu<?phpdefine( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) );
class sohu
{
public function getAddressList($username, $password)
{
$name=explode('@', $username);
$username=$name[0];
$ch = curl_init();
$encodeurl = "http://passport.sohu.com/sso/login.jsp?userid=".urlencode($username . "@sohu.com") . "&password=".md5($password)."&appid=1000&persistentcookie=0&s=".time()."343&b=2&w=1024&pwdtype=1";
curl_setopt($ch, CURLOPT_URL, $encodeurl);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR );
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$contents = curl_exec( $ch );
if ( strpos( $contents, "success" ) === false )
{
return 0;
}
curl_setopt($ch, CURLOPT_URL, "http://mail.sohu.com/bapp/128/main#addressList");
$contents = curl_exec($ch);
if(false == $contents){
curl_close( $ch );
return false;
}else{
curl_close( $ch );
return $this->parserContent($contents);
}
}
function parserContent($content){
preg_match_all("/var addresses = '(.*)';/Umsi",$content,$data);
$numList= json_decode( $data[1][0]);
$contactList = array();
foreach ($numList->contact as $val){
$obj = new stdClass;
$obj->name = $val->nickname;
$obj->nickname = $val->pinyin;
$obj->emailAddress = $val->email;
if($obj->nickname==""){
$obj->nickname = $obj->name;
}
$contactList[] = $obj;
}
if( count($contactList) == 0 ){
return false;
}else{
return $contactList;
}
}
}$test = new sohu();
$contects = $test->getAddressList('[email protected]', '123456');
var_dump($contects);?>
http://mail.sohu.com/bapp/128/main#addressList
128应该是不同用户不同获取的值,那个测试账号是128,你的可能不是。
建议楼主还是不要这种功能了吧,因为人家网站只要改版,写的接口就都白写了,还得重新模拟抓取。无奈国内没有提供api来调用,建议楼主把国内的都去掉吧,国外的比如gmail、、hotmail都有提供api来直接获取联系人的。