朋友网关于QQ相关的PHP代码(研究QQ的绝佳资料)(2)

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;
           
        }
    }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/e7cf048b808aaaaf76e4422e219f844a.html