首页  >  文章  >  后端开发  >  PHP获取QQ邮箱好友的具体代码讲解_PHP教程

PHP获取QQ邮箱好友的具体代码讲解_PHP教程

WBOY
WBOY原创
2016-07-15 13:28:271460浏览

目前,大家都在使用QQ,并且还将QQ附带的一些其他软件当做自己的日常使用工具。今天我们就向大家介绍有关如何运用具体的PHP获取QQ邮箱好友的代码如下:

<ol class="dp-xml">
<li class="alt"><span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span></span></li>
<li class=""><span>/**   </span></li>
<li class="alt"><span>* @file class.qqhttp.php  </span></li>
<li class=""><span>* qq邮箱登陆获取类  </span></li>
<li class="alt">
<span>* @author wc</span><strong><font color="#006699"><span class="tag"><span class="tag-name">cao8222</span></span></font></strong><span>@gmail.com</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> </span>
</li>
<li class=""><span>* @date 2009-04-27  </span></li>
<li class="alt"><span> */  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>class QQHttp {  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>    var $</span><span class="attribute"><font color="#ff0000">cookie</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">''</font></span><span>;  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>    function __cunstrut() {  </span></li>
<li class=""><span>    }  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>    function makeForm() {  </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">form</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(  </span>
</li>
<li class="">
<span>            'url' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> "http://mail.qq.com/cgi-bin/loginpage",  </span>
</li>
<li class="alt"><span>        );  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">data</font></span><span> = $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>curlFunc($form);  </span>
</li>
<li class="alt">
<span>        preg_match('/</span><span class="attribute"><font color="#ff0000">name</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"ts"</font></span><span></span><span class="attribute"><font color="#ff0000">svalue</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"(d+)"</font></span><span>/',$data['html'], $tspre);  </span>
</li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">ts</font></span><span> = $tspre[1];  </span>
</li>
<li class="alt">
<span>        preg_match('/</span><span class="attribute"><font color="#ff0000">action</font></span><span>="http://(md+).mail.qq.com/',$data['html'], $server);  </span>
</li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">server_no</font></span><span> = $server[1];  </span>
</li>
<li class="alt"><span> </span></li>
<li class=""><span>        /*  login.html 载入 */  </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">html</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">file_get_contents</font></span><span>(dirname(__FILE__).'/login.htm');  </span>
</li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">html</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">str_replace</font></span><span>('{_ts_}',$ts, $html);  </span>
</li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">html</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">str_replace</font></span><span>('{_server_no_}',$server_no, $html);  </span>
</li>
<li class=""><span>        return $html;  </span></li>
<li class="alt"><span>    }  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>    function curlFunc($array)  </span></li>
<li class=""><span>    {  </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">ch</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">curl_init</font></span><span>();  </span>
</li>
<li class=""><span>        curl_setopt($ch, CURLOPT_URL, $array['url']);  </span></li>
<li class="alt"><span>        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  </span></li>
<li class=""><span>        if( isset($array['header']) && $array['header'] ) {  </span></li>
<li class="alt"><span>            curl_setopt($ch, CURLOPT_HEADER, 1);  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt"><span>        if(isset($array['httpheader'])) {  </span></li>
<li class=""><span>            curl_setopt($ch, CURLOPT_HTTPHEADER, $array['httpheader']);  </span></li>
<li class="alt"><span>        }  </span></li>
<li class=""><span>        if(isset($array['referer'])) {  </span></li>
<li class="alt"><span>            curl_setopt($ch, CURLOPT_REFERER, $array['referer']);  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt"><span>        if( isset($array['post']) ) {  </span></li>
<li class=""><span>            curl_setopt($ch, CURLOPT_POST, 1 );  </span></li>
<li class="alt"><span>            curl_setopt($ch, CURLOPT_POSTFIELDS, $array['post']);  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt"><span>        if( isset($array['cookie']) ){  </span></li>
<li class=""><span>            curl_setopt($ch, CURLOPT_COOKIE, $array['cookie']);  </span></li>
<li class="alt"><span>        }  </span></li>
<li class=""><span>        $r['erro'] = curl_error($ch);  </span></li>
<li class="alt"><span>        $r['errno'] = curl_errno($ch);  </span></li>
<li class=""><span>        $r['html'] = curl_exec($ch);  </span></li>
<li class="alt"><span>        $r['http_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);  </span></li>
<li class=""><span>        curl_close($ch);  </span></li>
<li class="alt"><span>        return $r;  </span></li>
<li class=""><span>    }  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>    /**   </span></li>
<li class="alt"><span>     * 获取验证码图片和cookie  </span></li>
<li class=""><span>     * @param Null  </span></li>
<li class="alt"><span>     *   </span></li>
<li class="">
<span>     * @return array('img'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>String, 'cookie'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>String)  </span>
</li>
<li class="alt"><span>     */  </span></li>
<li class=""><span>    function getVFCode ()   </span></li>
<li class="alt"><span>    {  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">vfcode</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(  </span>
</li>
<li class="alt">
<span>            'header' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> true,  </span>
</li>
<li class="">
<span>            'cookie' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> false,  </span>
</li>
<li class="alt">
<span>            'url'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>'http://ptlogin2.qq.com/getimage?</span><span class="attribute"><font color="#ff0000">aid</font></span><span>='.$_GET['aid</span><span class="attribute-value"><font color="#0000ff">'].'</font></span><span>&'.@$_GET['t'],  </span>
</li>
<li class=""><span>        );  </span></li>
<li class="alt"><span> </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">r</font></span><span> = $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>curlFunc($vfcode);  </span>
</li>
<li class="alt"><span>        if ($r['http_code'] != 200 ) return false;  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">data</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">split</font></span><span>("n", $r['html']);  </span>
</li>
<li class="alt">
<span>        preg_match('/</span><span class="attribute"><font color="#ff0000">verifysession</font></span><span>=([^;]+);/',$data[5], $temp);  </span>
</li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">cookie</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">trim</font></span><span>($temp[1]);  </span>
</li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">img</font></span><span> = $data[9];  </span>
</li>
<li class="">
<span>        return  array('img'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>$img,'cookie'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>$cookie);  </span>
</li>
<li class="alt"><span>    }  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>    /**   </span></li>
<li class=""><span>     * 登陆qq邮箱  </span></li>
<li class="alt"><span>     *   </span></li>
<li class=""><span>     * @param $cookie getvfcode中生成的cookie  </span></li>
<li class="alt"><span>     *   </span></li>
<li class=""><span>     * @return array(  </span></li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">sid</font></span><span>=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>String , //用户认证的唯一标示  </span>
</li>
<li class="">
<span>     *   </span><span class="attribute"><font color="#ff0000">login</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> Boolean, //true 登陆成功 ,false 登陆失败  </span>
</li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">server_no</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> String // 服务器编号  </span>
</li>
<li class="">
<span>     *   </span><span class="attribute"><font color="#ff0000">active</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> Boolean //true 已开通 ,false 未开通 邮箱  </span>
</li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">cookie</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> String // 获取数据cookie  </span>
</li>
<li class=""><span>     *  </span></li>
<li class="alt"><span>     * );  </span></li>
<li class=""><span>     */  </span></li>
<li class="alt"><span>    function login($cookie)   </span></li>
<li class=""><span>    {  </span></li>
<li class="alt"><span>        /* 生成参数字符串 */  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">post</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>();  </span>
</li>
<li class="alt">
<span>        foreach($_POST as $</span><span class="attribute"><font color="#ff0000">k</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> $v) {  </span>
</li>
<li class=""><span>            $post[] = $k.'='.urlencode($v);  </span></li>
<li class="alt"><span>        }  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">poststr</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">implode</font></span><span>('&',$post);  </span>
</li>
<li class="alt"><span>        $r['server_no'] = $_GET['server_no'];  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">login</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(  </span>
</li>
<li class="">
<span>            'url'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>'http://'.$r['server_no'].'.mail.qq.com/cgi-bin/login?</span><span class="attribute"><font color="#ff0000">sid</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>,2,zh_CN',  </span>
</li>
<li class="alt">
<span>            'header' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> true,  </span>
</li>
<li class="">
<span>            'cookie' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> '</span><span class="attribute"><font color="#ff0000">verifysession</font></span><span>='.$cookie,  </span>
</li>
<li class="alt">
<span>            'referer' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> 'http://mail.qq.com/cgi-bin/loginpage',  </span>
</li>
<li class="">
<span>            'httpheader'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>array(  </span>
</li>
<li class="alt"><span>                "Host: " . $r['server_no'] . '.mail.qq.com',  </span></li>
<li class=""><span>                "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 FirePHP/0.2.4",  </span></li>
<li class="alt"><span>                "Content-Type: application/x-www-form-urlencoded",  </span></li>
<li class=""><span>            ),  </span></li>
<li class="alt">
<span>            'post' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> $poststr ,  </span>
</li>
<li class=""><span>        );  </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">data</font></span><span> = $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>curlFunc($login);  </span>
</li>
<li class=""><span>        $data['html'] = iconv("gb2312", "UTF-8", $data['html']);  </span></li>
<li class="alt"><span>        if ($data['http_code'] != 200) {  </span></li>
<li class="">
<span>            $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>error($data);  </span>
</li>
<li class="alt"><span>            return false;  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>        /* 测试数据 */  </span></li>
<li class="alt"><span>        //$data['html'] =file_get_contents('./r.txt');  </span></li>
<li class=""><span>        $r['uin'] = $_POST['uin'];  </span></li>
<li class="alt"><span>        /* 登陆错误的判断 */  </span></li>
<li class="">
<span>        if (preg_match('|</span><span class="attribute"><font color="#ff0000">errtype</font></span><span>=(d)|', $data['html'], $temp_err)) {  </span>
</li>
<li class="alt"><span>            $r['login'] = false;  </span></li>
<li class=""><span>            if ($temp_err[1] == 1) {  </span></li>
<li class="alt"><span>                $r['msg'] = '账号和密码错误';  </span></li>
<li class=""><span>            } elseif ($temp_err[1] == 2) {  </span></li>
<li class="alt"><span>                $r['msg'] = '验证码错误';  </span></li>
<li class=""><span>            }  </span></li>
<li class="alt"><span>            return $r;  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt"><span>        /* 登陆成功 */  </span></li>
<li class="">
<span>        preg_match('|</span><span class="attribute"><font color="#ff0000">urlHead</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"([^"</font></span><span>]+)"|i',$data['html'],$temp_url);  </span>
</li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">urlhead</font></span><span> = $temp_url[1];  </span>
</li>
<li class="">
<span>        if (preg_match('|frame_html?</span><span class="attribute"><font color="#ff0000">sid</font></span><span>=([^"]+)"|i',$data['html'],$temp_sid) ) {  </span>
</li>
<li class="alt"><span>            $r['sid'] = $temp_sid[1];  </span></li>
<li class=""><span>            $r['active'] = true;  </span></li>
<li class="alt">
<span>        } elseif (preg_match('|autoactivation?</span><span class="attribute"><font color="#ff0000">sid</font></span><span>=([^&]+)?&|i',$data['html'],$temp_sid) ) {  </span>
</li>
<li class=""><span>            $r['sid'] = $temp_sid[1];  </span></li>
<li class="alt"><span>            $r['active'] = false;  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt"><span>        /* 登录后cookie的获取 ,在后续操作中用到 */  </span></li>
<li class=""><span>        if (preg_match_all('|Set-Cookie:([^=]+=[^;]+)|i', $data['html'], $new_cookies) ) {  </span></li>
<li class="alt">
<span>            $</span><span class="attribute"><font color="#ff0000">cookiestr</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">implode</font></span><span>('; ', $new_cookies[1]);  </span>
</li>
<li class="">
<span>            $cookiestr </span><span class="attribute"><font color="#ff0000">.</font></span><span>= </span><span class="attribute-value"><font color="#0000ff">'; verifysession='</font></span><span>.$cookie;  </span>
</li>
<li class="alt"><span>        }  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>        $r['login'] = true;  </span></li>
<li class=""><span>        $r['cookie'] = $cookiestr;  </span></li>
<li class="alt"><span>        return $r;  </span></li>
<li class=""><span>    }  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>    function openEmail($param)   </span></li>
<li class="alt"><span>    {  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">openEmail</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(  </span>
</li>
<li class="alt">
<span>            'url'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>'http://'.$param['server_no'].'.mail.qq.com/cgi-bin/autoactivation?</span><span class="attribute"><font color="#ff0000">actmode</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">6</font></span><span>&</span><span class="attribute"><font color="#ff0000">sid</font></span><span class="attribute-value"><font color="#0000ff">sid</font></span><span>='.$param['sid'],  </span>
</li>
<li class="">
<span>            'header' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> true,  </span>
</li>
<li class="alt">
<span>            'cookie' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> $param['cookie'],  </span>
</li>
<li class="">
<span>            'referer' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> 'http://'.$param['server_no'].'mail.qq.com/cgi-bin/autoactivation?</span><span class="attribute"><font color="#ff0000">sid</font></span><span>='.$param['sid</span><span class="attribute-value"><font color="#0000ff">'].'</font></span><span>&</span><span class="attribute"><font color="#ff0000">action</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">reg_activate</font></span><span>&</span><span class="attribute"><font color="#ff0000">actmode</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">6</font></span><span>',   </span>
</li>
<li class="alt">
<span>            'httpheader'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>array(  </span>
</li>
<li class=""><span>                "Host: " . $param['server_no'] . '.mail.qq.com',  </span></li>
<li class="alt">
<span>                'Accept-Charset: gb2312,utf-8;</span><span class="attribute"><font color="#ff0000">q</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>.7,*;</span><span class="attribute"><font color="#ff0000">q</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>.7',  </span>
</li>
<li class=""><span>                "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 FirePHP/0.2.4",  </span></li>
<li class="alt"><span>            ),  </span></li>
<li class=""><span>        );  </span></li>
<li class="alt"><span> </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">data</font></span><span> =  $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>curlFunc($openEmail);  </span>
</li>
<li class="alt">
<span>        if (preg_match('|</span><span class="attribute"><font color="#ff0000">Set-Cookie:qqmail_activated</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>|i', $data['html'])) {  </span>
</li>
<li class=""><span>            $param['active'] = true;  </span></li>
<li class="alt">
<span>            $param['cookie'] = $param['cookie'] .'; </span><span class="attribute"><font color="#ff0000">qqmail_activated</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>; </span><span class="attribute"><font color="#ff0000">qqmail_alias</font></span><span>=';  </span>
</li>
<li class=""><span>        }  </span></li>
<li class="alt"><span>        return $param;  </span></li>
<li class=""><span>    }  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>    /**   </span></li>
<li class="alt"><span>     *   </span></li>
<li class=""><span>     * 获取friends数据   </span></li>
<li class="alt"><span>     *   </span></li>
<li class="">
<span>     * @param $</span><span class="attribute"><font color="#ff0000">param</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(  </span>
</li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">sid</font></span><span>=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>String , //用户认证的唯一标示  </span>
</li>
<li class="">
<span>     *   </span><span class="attribute"><font color="#ff0000">login</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> Boolean, //true 登陆成功 ,false 登陆失败  </span>
</li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">server_no</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> String // 服务器编号  </span>
</li>
<li class="">
<span>     *   </span><span class="attribute"><font color="#ff0000">active</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> Boolean //true 已开通 ,false 未开通 邮箱  </span>
</li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">cookie</font></span><span> =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> String // 获取数据cookie  </span>
</li>
<li class=""><span>     *  </span></li>
<li class="alt"><span>     * );  </span></li>
<li class=""><span>     * @return Array(  </span></li>
<li class="alt">
<span>     *   </span><span class="attribute"><font color="#ff0000">key</font></span><span>=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>value, // key:qq号,value: nickname  </span>
</li>
<li class=""><span>     * );  </span></li>
<li class="alt"><span>     */  </span></li>
<li class=""><span>    function getFriends($param)  </span></li>
<li class="alt"><span>    {  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">friend</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(  </span>
</li>
<li class="">
<span>            'url'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>'http://'.$param['server_no'].'.mail.qq.com/cgi-bin/addr_listall?</span><span class="attribute"><font color="#ff0000">type</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">user</font></span><span>&&</span><span class="attribute"><font color="#ff0000">category</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">all</font></span><span>&</span><span class="attribute"><font color="#ff0000">sid</font></span><span class="attribute-value"><font color="#0000ff">sid</font></span><span>='.$param['sid'],  </span>
</li>
<li class="alt">
<span>            'header' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> true,  </span>
</li>
<li class="">
<span>            'cookie' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> $param['cookie'],  </span>
</li>
<li class="alt">
<span>            'referer' =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> 'http://m151.mail.qq.com/cgi-bin/addr_listall?</span><span class="attribute"><font color="#ff0000">sid</font></span><span>='.$param['sid</span><span class="attribute-value"><font color="#0000ff">'].'</font></span><span>&</span><span class="attribute"><font color="#ff0000">sorttype</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>&</span><span class="attribute"><font color="#ff0000">category</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">common</font></span><span>',  </span>
</li>
<li class="">
<span>            'httpheader'=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>array(  </span>
</li>
<li class="alt"><span>                "Host: " . $param['server_no'] . '.mail.qq.com',  </span></li>
<li class="">
<span>                'Accept-Charset:utf-8;</span><span class="attribute"><font color="#ff0000">q</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>.7,*;</span><span class="attribute"><font color="#ff0000">q</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>.7',  </span>
</li>
<li class="alt"><span>                "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 FirePHP/0.2.4",  </span></li>
<li class=""><span>            ),  </span></li>
<li class="alt"><span>        );  </span></li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">r</font></span><span> = $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>curlFunc($friend);  </span>
</li>
<li class="alt"><span>        if ($r['http_code'] != 200) {  </span></li>
<li class="">
<span>            $this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>error($r);  </span>
</li>
<li class="alt"><span>            return false;  </span></li>
<li class=""><span>        }  </span></li>
<li class="alt">
<span>        $</span><span class="attribute"><font color="#ff0000">data</font></span><span> =  $r['html'];  </span>
</li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">preg</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">preg_match_all</font></span><span>('|</span><strong><font color="#006699"><span class="tag"><span class="tag-name">p</span></span></font></strong><span> </span><span class="attribute"><font color="#ff0000">class</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"L_n"</font></span><strong><font color="#006699"><span class="tag">></span><span class="tag"><span class="tag-name">span</span><span class="tag">></span><span class="tag"><span class="tag-name">img</span></span></span></font></strong><span> </span><span class="attribute"><font color="#ff0000">class</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"L_q"</font></span><span> </span><span class="attribute"><font color="#ff0000">name</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">qqplusimg</font></span><span> </span><span class="attribute"><font color="#ff0000">key</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"(d+)"</font></span><span>[^</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>]+</span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> ([^</span><span class="tag"><strong><font color="#006699"></font></strong></span><span>]+)</span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">span</span><span class="tag">></span><span class="tag"></span><span class="tag-name">p</span><span class="tag">></span></font></strong><span>|i', $data, $temp_list);  </span>
</li>
<li class="alt">
<span>        if ($</span><span class="attribute"><font color="#ff0000">preg</font></span><span> == 0) return array();  </span>
</li>
<li class="">
<span>        $</span><span class="attribute"><font color="#ff0000">list</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">array_combine</font></span><span>($temp_list[1],$temp_list[2]);  </span>
</li>
<li class="alt"><span>        return $list;  </span></li>
<li class=""><span>    }  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>    /**   </span></li>
<li class="alt"><span>     * 错误显示  </span></li>
<li class=""><span>     *   </span></li>
<li class="alt"><span>     * @param $str array  </span></li>
<li class=""><span>     *   </span></li>
<li class="alt"><span>     * @return   </span></li>
<li class=""><span>     */  </span></li>
<li class="alt"><span>    function error($str) {  </span></li>
<li class=""><span>        $str['html'] = str_replace('script','', $str['html']);  </span></li>
<li class="alt"><span>        var_dump($str);  </span></li>
<li class=""><span>        exit;  </span></li>
<li class="alt"><span>    }  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span>
</li>
</ol>

怎么样,通过以上对于PHP获取QQ邮箱好友的代码的介绍,大家是否已经完全掌握了呢?


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446439.htmlTechArticle目前,大家都在使用QQ,并且还将QQ附带的一些其他软件当做自己的日常使用工具。今天我们就向大家介绍有关如何运用 具体的PHP获取QQ邮箱...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn