求一份PHP获取136,126,sina,soho,tom,gmail等各大常用邮箱联系人功能的源码

解决方案 »

  1.   

    好多年前,当开心网正火的时候,搞过这东西,一下子忘记了。也懒得google 了,陪你一起坐等答案。
      

  2.   

    百度了一下,都是curl去抓的,自己试试吧。
      

  3.   

    灰常感谢现在还有sina,yahoo,sohu的没搞定,我想这些先能跑通,然后整合到thinkphp里面去
      

  4.   

    终于忙完了,才来论坛,回复晚见谅。待我注册几个号跟踪一下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);?>
      

  5.   

    从一个使用者的角度来说, 如果不是用oauth的, 我是不会用这种自动获取联系人的东西的....
      

  6.   


    http://mail.sohu.com/bapp/128/main#addressList
    128应该是不同用户不同获取的值,那个测试账号是128,你的可能不是。
    建议楼主还是不要这种功能了吧,因为人家网站只要改版,写的接口就都白写了,还得重新模拟抓取。无奈国内没有提供api来调用,建议楼主把国内的都去掉吧,国外的比如gmail、、hotmail都有提供api来直接获取联系人的。
      

  7.   

    最近hotmail的改版引起的直接结果是之前搞的邮箱联系人功能失效,还没找到更好的解决方案,悲催~~~