富贵资源网 Design By www.hznty.com

本文实例讲述了PHP模拟登陆163邮箱发邮件及获取通讯录列表的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:
<"Content-Type: text/html; charset=UTF-8");
    error_reporting(0);
    /**
     * 登陆
     * $user 163用户名
     * $pass 密码
    **/
    function login($user,$pass){
        //登陆
        $url = 'http://reg.163.com/logins.jsp"info" id="eHint">(.*"text/javascript">alert("'.$infos['0']['1'].'");history.go(-1);</script>');
        }else{     
            $G_ROOT = dirname(__FILE__);
            file_put_contents($G_ROOT.'/cache/cookie', $cookie);
            return $cookie;
        }
    }
    /**
     *
     * $data['url'] 请求地址
     * $data['data_post'] post数据
     * $data['cookie']
     *
    **/
    function curl($data){
        $url = $data['url'];
        $data_post= $data['data_post']? $data['data_post']: false;
        $cookie = $data['cookie'];     
        $headers = array(
            'User-Agent'        => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0',
            'Referer'    => 'http://www.163.com'
        );
        $ch = curl_init($url);  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);     
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);  //cookie文件 登陆之后
        //POST 提交
        if($data_post){
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_post);
        }
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }

希望本文所述对大家的php程序设计有所帮助。

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com