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

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 :
                    //对方允许任何人加为好友
                    return QQ_ADDTOLIST_SUCCESS;
                    break;
                case 1 :
                    //需要验证
                    return QQ_ADDTOLIST_NEEDAUTH;
                    break;
                case 3 :
                    //不允许任何人加为好友
                    return QQ_ADDTOLIST_REFUSE;
                    break;
                default :
                    //未知的代码
                    return QQ_ADDTOLIST_UNKNOWN;
                    break;
            }
        }
        else
        {
            //返回失败
            return QQ_RETURN_FAILED;
        }
    }

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

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