最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

朋友網(wǎng)關(guān)于QQ相關(guān)的PHP代碼(研究QQ的絕佳資料)

 更新時(shí)間:2015年01月26日 12:13:44   投稿:junjie  
這篇文章主要介紹了朋友網(wǎng)關(guān)于QQ相關(guān)的PHP代碼(研究QQ的絕佳資料),本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

<?
/***************************************

****************************************/
error_reporting(E_ALL ^ E_NOTICE);

require_once( 'http.inc.php' );
require_once( 'class.Chinese.php');


//成功2xx
    define( 'QQ_RETURN_SUCCESS',    200 );
    define( 'QQ_LOGIN_SUCCESS',    201 );
    define( 'QQ_LIST_NONE',        202 );
    define( 'QQ_ADDTOLIST_SUCCESS',    203 );
    define( 'QQ_REPLYADD_SUCCESS',    204 );
    define( 'QQ_GETMSG_NONE',    205 );

//警告3xx
    define( 'QQ_ADDTOLIST_NEEDAUTH',300 );
    define( 'QQ_ADDTOLIST_REFUSE',    301 );
    define( 'QQ_ADDTOLIST_UNKNOWN',    302 );

//失敗4xx
    define( 'QQ_RETURN_FAILED',    400 );
    define( 'QQ_LIST_ERROR',    401 );
    define( 'QQ_GETMSG_ERROR',    402 );

//在線(xiàn)狀態(tài)
    define( 'QQ_STATUS_ONLINE',    10);
    define( 'QQ_STATUS_OFFLINE',    20);
    define( 'QQ_STATUS_BUSY',    30);

//血型
    $QQ_DATA_BT = array
        (
=> '',
=> 'A型',
=> 'B型',
=> 'O型',
=> 'AB型',
=> '其他'
        );

//星座
    $QQ_DATA_CO = array
        (
=> '',
=> '水瓶座',
=> '雙魚(yú)座',
=> '牡羊座',
=> '金牛座',
=> '雙子座',
=> '巨蟹座',
=> '獅子座',
=> '處女座',
=> '天秤座',
=> '天蝎座',
=> '射手座',
=> '摩羯座'
        );

//生肖
    $QQ_DATA_SH = array
        (
=> '',
=> '鼠',
=> '牛',
=> '虎',
=> '兔',
=> '龍',
=> '蛇',
=> '馬',
=> '羊',
=> '猴',
=> '雞',
=> '狗',
=> '豬'
        );

//性別
    $QQ_DATA_SX = array
        (
=> '男',
=> '女'
        );

class QQClient
{
    var $uin;
    var $pwd;

    var $server    =    'kconn.tencent.com';
    //備用:219.133.51.11
    var $port    =    21001;
    //備用:8000
    var $httpclient;
    var $chs    =    NULL;

    function QQClient($uin,$pwd)
    {
        $this->uin = $uin;
        $this->pwd = $pwd;
    }

    function encode($str)
    /*
        說(shuō)明:把KEY1=VAL1&KEY2=VAL2格式變?yōu)閿?shù)組
    */
    {
        $arr = explode('&' , $str);
        $return = array();
        foreach($arr as $k=>$v)
        {
            list($key,$val) = explode('=',$v);
            $return[$key] = $val;
            $this->chs = NULL;
        }
        return $return;
    }

    function utf8_to_gb2312($str)
    {
        $this->chs = new Chinese("UTF8","GB2312", $str );
        return $this->chs->ConvertIT();
    }

    function gb2312_to_utf8($str)
    {
        $this->chs = new Chinese("GB2312","UTF8", $str );
        return $this->chs->ConvertIT();
    }

    function query($str)
    {
        $this->httpclient = new http( HTTP_V11, true );
        $this->httpclient->host = 'kconn.tencent.com';
        $this->httpcilent->port = 21001;

        $query = $this->encode($str);
        $status = $this->httpclient->post( '', $query, '' );
        if ( $status == HTTP_STATUS_OK ) {
            return $this->httpclient->get_response_body();
        }
        else
        {
            print_r($this->httpclient);
            return false;
        }
        $this->httpclient->disconnect();
        unset($this->httpclient);
    }

    function split_str($str)
    {
        $arr = explode("," , $str);
        if($arr[count($arr)-1] == NULL)
        {
            unset($arr[count($arr)-1]);
        }
        return $arr;
    }

    function login()
    {
        //登陸
        //VER=1.1&CMD=Login&SEQ=&UIN=&PS=&M5=1&LC=9326B87B234E7235
        $str = "VER=1.1&CMD=Login&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&PS=".md5($this->pwd)."&M5=1&LC=9326B87B234E7235";
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //返回成功
            if($return['RS']==0)
            {
                //登陸成功
                return QQ_LOGIN_SUCCESS;
            }
            else
            {
                //登陸失敗
                $GLOBALS['QQ_ERROR_MSG'] = $this->utf8_to_gb2312($return['RA']);
                return QQ_LOGIN_FAILED;
            }
        }
        else
        {
            //返回失敗
            return QQ_RETURN_FAILED;
           
        }
    }

    function getFriendsList()
    {
        //得到好友列表
        //VER=1.1&CMD=List&SEQ=&UIN=&TN=160&UN=0
        $str = "VER=1.1&CMD=List&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&TN=160&UN=0";
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //返回成功
            return $this->split_str($return['UN']);
        }
        else
        {
            //返回失敗
            return QQ_RETURN_FAILED;
           
        }
    }

    function getOnlineList()
    {
        //得到在線(xiàn)好友列表
        //VER=1.1&CMD=Query_Stat&SEQ=&UIN=&TN=50&UN=0
        $str = "VER=1.1&CMD=Query_Stat&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&TN=50&UN=0";
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //返回成功
            if($return['SN'] > 0)
            {
                //在線(xiàn)好友數(shù)>0
                $uns = $this->split_str($return['UN']);    //號(hào)碼列表
                $nks = $this->split_str($return['NK']); //昵稱(chēng)列表
                $sts = $this->split_str($return['ST']); //狀態(tài)列表
                $fcs = $this->split_str($return['FC']); //頭像列表
                $error = 0;
                ((count($uns)==count($nks))==(count($sts)==count($fcs)))==(count($nks)==count($sts)) ?
                    $num = count($uns)
                    :
                    $error = 1;
                ;
                if($error == 1) return QQ_LIST_ERROR;
                $arr = array();
                for($i=0;$i<$num;$i++)
                {
                    $arr[] = array(
                        "UN" => $uns[$i] ,
                        "NK" => $this->utf8_to_gb2312($nks[$i]) ,
                        "ST" => $sts[$i] ,
                        "FC" => $fcs[$i]
                    );
                }
                return ($arr);
            }
            else
            {
                //在線(xiàn)好友數(shù)<=0
                return QQ_LIST_NONE;
            }
           
        }
        else
        {
            //返回失敗
            return QQ_RETURN_FAILED;
               
        }
    }

    function getInfo($uin)
    {
        //得到好友信息
        //AD為聯(lián)系地址,AG為年齡,EM為MAIL,F(xiàn)C為頭像,HP為網(wǎng)站,JB為職業(yè),PC為郵編,PH為聯(lián)系電話(huà),PR為簡(jiǎn)介,PV為省,RN為真實(shí)名稱(chēng),SC為畢業(yè)院校,SX為性別,UN為QQ號(hào),NK為QQ昵稱(chēng)
        //以下注釋研究 by Hackfan
        //BT為血型,CO為星座,CT為城市,CY為國(guó)家,MO為移動(dòng)電話(huà),SH生肖
        //LV為查詢(xún)的號(hào)碼(1為精簡(jiǎn)查詢(xún),2為普通查詢(xún),3為詳細(xì)查詢(xún))
        //CV未知,ID未知(身份證?),MT未知,MV未知,
        //VER=1.1&CMD=GetInfo&SEQ=&UIN=&LV=3&UN=
        $str = "VER=1.1&CMD=GetInfo&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&LV=3&UN=".$uin;
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //返回成功
            $arr = array
                (
                    'AD' => $this->utf8_to_gb2312($return['AD']),        //聯(lián)系地址
                    'AG' => $this->utf8_to_gb2312($return['AG']),        //年齡
                    'BT' => $return['BT'],        //血型
                    'CO' => $return['CO'],        //星座
                    'CT' => $this->utf8_to_gb2312($return['CT']),        //城市
                    'CY' => $this->utf8_to_gb2312($return['CY']),        //國(guó)家
                    'EM' => $this->utf8_to_gb2312($return['EM']),        //Email
                    'FC' => $return['FC'],        //頭像
                    'HP' => $this->utf8_to_gb2312($return['HP']),        //網(wǎng)站
                    'JB' => $this->utf8_to_gb2312($return['JB']),        //職業(yè)
                    'MO' => $return['MO'],        //移動(dòng)電話(huà)
                    'PC' => $this->utf8_to_gb2312($return['PC']),        //郵編
                    'PH' => $this->utf8_to_gb2312($return['PH']),        //聯(lián)系電話(huà)
                    'PR' => $this->utf8_to_gb2312($return['PR']),        //簡(jiǎn)介
                    'PV' => $this->utf8_to_gb2312($return['PV']),        //省
                    'RN' => $this->utf8_to_gb2312($return['RN']),        //真實(shí)姓名
                    'SC' => $this->utf8_to_gb2312($return['SC']),        //畢業(yè)院校
                    'SH' => $return['SH'],        //生肖
                    'SX' => $return['SX'],        //性別
                    'UN' => $return['UN'],        //QQ號(hào)
                    'NK' => $this->utf8_to_gb2312($return['NK'])        //昵稱(chēng)
                );
            return $arr;
        }
        else
        {
            //返回失敗
            return QQ_RETURN_FAILED;
               
        }

    }

    function addFriend($uin)
    {
        //添加新好友
        //VER=1.1&CMD=AddToList&SEQ=&UIN=&UN=
        $str = "VER=1.1&CMD=AddToList&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&UN=".$uin;
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //返回成功
            switch($return['CD'])
            {
                case 0 :
                    //對(duì)方允許任何人加為好友
                    return QQ_ADDTOLIST_SUCCESS;
                    break;
                case 1 :
                    //需要驗(yàn)證
                    return QQ_ADDTOLIST_NEEDAUTH;
                    break;
                case 3 :
                    //不允許任何人加為好友
                    return QQ_ADDTOLIST_REFUSE;
                    break;
                default :
                    //未知的代碼
                    return QQ_ADDTOLIST_UNKNOWN;
                    break;
            }
        }
        else
        {
            //返回失敗
            return QQ_RETURN_FAILED;
        }
    }

    function replyAdd($uin,$type,$msg)
    {
        //回應(yīng)添加好友
        //VER=1.1&CMD=Ack_AddToList&SEQ=&UIN=&UN=&CD=&RS=
        //CD為響應(yīng)狀態(tài),CD為0表示“通過(guò)驗(yàn)證”。CD為1表示“拒決加為對(duì)方為好友”。CD為2表示“為請(qǐng)求對(duì)方加為好友”。RS為你要請(qǐng)求的理由
        $str = "VER=1.2&CMD=Ack_AddToList&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&UN=".$uin."&CD=".$type."&RS=".$this->gb2312_to_utf8($msg);
        $return = $this->encode($this->query($str));
       
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //服務(wù)器成功得到信息
            return QQ_RETURN_SUCCESS;
        }
        else
        {
            //失敗
            return QQ_RETURN_FAILED;           
        }
    }

    function delFriend($uin)
    {
        //刪除好友
        //VER=1.1&CMD=DelFromList&SEQ=&UIN=&UN=
        $str = "VER=1.1&CMD=DelFromList&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&UN=$uin";
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //服務(wù)器成功得到信息
            return QQ_RETURN_SUCCESS;
        }
        else
        {
            //失敗
            return QQ_RETURN_FAILED;
        }
    }

    function changeStatus($status)
    {
        //改變狀態(tài)
        //VER=1.1&CMD=Change_Stat&SEQ=&UIN=&ST=
        //ST為要改變的狀態(tài),10為上線(xiàn),20為離線(xiàn),30為忙碌。
        $str = "VER=1.1&CMD=Change_stat&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&ST=".$status;
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //服務(wù)器成功得到信息
            return QQ_RETURN_SUCCESS;
        }
        else
        {
            //失敗
            return QQ_RETURN_FAILED;
        }
    }

    function logout()
    {
        //退出登陸
        //VER=1.1&CMD=Logout&SEQ=&UIN=
        $str = "VER=1.1&CMD=Logout&SEQ=".rand(1000,9000)."&UIN=".$this->uin;
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //服務(wù)器成功得到信息
            return QQ_RETURN_SUCCESS;
        }
        else
        {
            //失敗
            return QQ_RETURN_FAILED;
        }
    }

    function getMsg()
    {
        //獲得消息
        //VER=1.1&CMD=GetMsgEx&SEQ=&UIN=
        //MT表示消息類(lèi)型,99表示系統(tǒng)消息,9表示用戶(hù)消息。UN表示消息發(fā)送來(lái)源用戶(hù),MG表示發(fā)送的消息,MG消息可以表示某些特定的系統(tǒng)含意
        //當(dāng)MT=99時(shí):MG=10表示用戶(hù)上線(xiàn),MG=20表示用戶(hù)離線(xiàn),MG=30表示用戶(hù)忙碌
        $str = "VER=1.1&CMD=GetMsgEx&SEQ=".rand(1000,9000)."&UIN=".$this->uin;
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //服務(wù)器成功得到信息
            if($return['MN'] > 0)
            {
                //消息數(shù)>0
                $mts = $this->split_str($return['MT']);    //消息類(lèi)型
                $uns = $this->split_str($return['UN']); //發(fā)送者號(hào)碼
                $mgs = $this->split_str($return['MG']); //消息內(nèi)容
                $error = 0;
                (count($mts)==count($uns))==(count($uns)==count($mgs))?
                    $num = count($uns)
                    :
                    $error = 1;
                ;
                if($error == 1) return QQ_GETMSG_ERROR;    //出差錯(cuò)了
                $arr = array();
                for($i=0;$i<$num;$i++)
                {
                    $arr[] = array(
                        "MT" => $mts[$i] ,
                        "UN" => $uns[$i] ,
                        "MG" => $this->utf8_to_gb2312($mgs[$i])
                    );
                }
                return ($arr);
            }
            else
            {
                //在線(xiàn)好友數(shù)<=0
                return QQ_GETMSG_NONE;
            }
        }
        else
        {
            //失敗
            return QQ_RETURN_FAILED;
        }
    }

    function sendMsg($uin,$msg)
    {
        //發(fā)送消息
        //VER=1.1&CMD=CLTMSG&SEQ=&UIN=&UN=&MG=
        $str = "VER=1.1&CMD=CLTMSG&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&UN=".$uin."&MG=".$this->gb2312_to_utf8($msg);
        $return = $this->encode($this->query($str));
        if($return['RES']==0 and $return['UIN'] == $this->uin)
        {
            //服務(wù)器成功得到信息
            return QQ_RETURN_SUCCESS;
        }
        else
        {
            //失敗
            return QQ_RETURN_FAILED;
        }
    }

}
?>

相關(guān)文章

  • php+mysql開(kāi)發(fā)中的經(jīng)驗(yàn)與常識(shí)小結(jié)

    php+mysql開(kāi)發(fā)中的經(jīng)驗(yàn)與常識(shí)小結(jié)

    這篇文章主要介紹了php+mysql開(kāi)發(fā)中的經(jīng)驗(yàn)與常識(shí),簡(jiǎn)單總結(jié)分析了php+mysql數(shù)據(jù)庫(kù)程序設(shè)計(jì)中的命名規(guī)范、數(shù)據(jù)庫(kù)表、字段、索引等相關(guān)設(shè)計(jì)與使用規(guī)范,需要的朋友可以參考下
    2019-03-03
  • PHP實(shí)現(xiàn)仿Google分頁(yè)效果的分頁(yè)函數(shù)

    PHP實(shí)現(xiàn)仿Google分頁(yè)效果的分頁(yè)函數(shù)

    這篇文章主要介紹了PHP實(shí)現(xiàn)仿Google分頁(yè)效果的分頁(yè)函數(shù),實(shí)例分析了php實(shí)現(xiàn)分頁(yè)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-07-07
  • PHP計(jì)數(shù)器的實(shí)現(xiàn)代碼

    PHP計(jì)數(shù)器的實(shí)現(xiàn)代碼

    本篇文章是對(duì)PHP計(jì)數(shù)器的實(shí)現(xiàn)代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • 淺析php插件 HTMLPurifier HTML解析器

    淺析php插件 HTMLPurifier HTML解析器

    本篇文章是對(duì)php插件 HTMLPurifier HTML解析器進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-07-07
  • php實(shí)現(xiàn)用于刪除整個(gè)目錄的遞歸函數(shù)

    php實(shí)現(xiàn)用于刪除整個(gè)目錄的遞歸函數(shù)

    這篇文章主要介紹了php實(shí)現(xiàn)用于刪除整個(gè)目錄的遞歸函數(shù),涉及php遞歸算法與目錄操作技巧,需要的朋友可以參考下
    2015-03-03
  • php中關(guān)于hook鉤子函數(shù)底層理解

    php中關(guān)于hook鉤子函數(shù)底層理解

    對(duì)"鉤子"這個(gè)概念其實(shí)不熟悉,最近看到一個(gè)php框架中用到這種機(jī)制來(lái)擴(kuò)展項(xiàng)目,所以大概來(lái)了解下。 所謂Hook機(jī)制,是從Windows編程中流行開(kāi)的一種技術(shù)
    2023-01-01
  • PHP操作XML的教程詳解

    PHP操作XML的教程詳解

    這篇文章主要為大家詳細(xì)介紹了PHP操作XML的方法,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)或工作有一定的參考價(jià)值,感興趣的可以了解一下
    2022-05-05
  • 學(xué)習(xí)php設(shè)計(jì)模式 php實(shí)現(xiàn)門(mén)面模式(Facade)

    學(xué)習(xí)php設(shè)計(jì)模式 php實(shí)現(xiàn)門(mén)面模式(Facade)

    這篇文章主要介紹了php設(shè)計(jì)模式中的門(mén)面模式,使用php實(shí)現(xiàn)門(mén)面模式,感興趣的小伙伴們可以參考一下
    2015-12-12
  • PHP中使用CURL獲取頁(yè)面title例子

    PHP中使用CURL獲取頁(yè)面title例子

    這篇文章主要介紹了PHP中使用CURL獲取頁(yè)面title例子,本文使用正則實(shí)現(xiàn)獲取頁(yè)面title、頁(yè)面編碼、<head>標(biāo)簽中的內(nèi)容,需要的朋友可以參考下
    2015-01-01
  • 關(guān)于PHP方法參數(shù)的那一些事

    關(guān)于PHP方法參數(shù)的那一些事

    這篇文章主要給大家介紹了關(guān)于PHP方法參數(shù)的那一些事,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01

最新評(píng)論

台东市| 龙南县| 大姚县| 饶阳县| 浦县| 桓仁| 柳江县| 万州区| 柯坪县| 深圳市| 芦山县| 义马市| 兴文县| 宣恩县| 彰武县| 利川市| 厦门市| 临江市| 英超| 德保县| 黎城县| 葵青区| 红原县| 庆安县| 万宁市| 蒲城县| 蚌埠市| 克什克腾旗| 晋江市| 资源县| 中方县| 遵化市| 新巴尔虎左旗| 肥东县| 黄石市| 邢台县| 长兴县| 土默特左旗| 汉寿县| 星座| 红原县|