This article mainly introduces the PHP Code related to QQ used by friend Gateway (excellent information on QQ). This article provides the implementation code directly. For more information, see
This article mainly introduces the PHP Code related to QQ used by friend Gateway (excellent information on QQ). This article provides the implementation code directly. For more information, see
The Code is as follows:
<?
/***************************************
****************************************/
Error_reporting (E_ALL ^ E_NOTICE );
Require_once ('HTTP. inc. php ');
Require_once ('class. Chinese. php ');
// Success 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 );
// Warning 3xx
Define ('qq _ ADDTOLIST_NEEDAUTH ', 300 );
Define ('qq _ ADDTOLIST_REFUSE ', 301 );
Define ('qq _ ADDTOLIST_UNKNOWN ', 302 );
// Failure 4xx
Define ('qq _ RETURN_FAILED ', 400 );
Define ('qq _ LIST_ERROR ', 401 );
Define ('qq _ GETMSG_ERROR ', 402 );
// Online status
Define ('qq _ STATUS_ONLINE ', 10 );
Define ('qq _ status_offline', 20 );
Define ('qq _ STATUS_BUSY ', 30 );
// Blood type
$ QQ_DATA_BT = array
(
=> '',
=> 'A ',
=> 'B ',
=> 'O type ',
=> 'AB type ',
=> 'Others'
);
// Constellation
$ QQ_DATA_CO = array
(
=> '',
=> 'Aquarius ',
=> 'Pisces ',
=> 'Sheepse ',
=> 'Taurus ',
=> 'Gemins ',
=> 'Loan ',
=> 'Leo ',
=> 'Virgo ',
=> 'Libra ',
=> 'Scorpio ',
=> 'Sagittarius ',
=> 'Capricorn'
);
// Chinese zodiac
$ QQ_DATA_SH = array
(
=> '',
=> 'Rat ',
=> 'Niu ',
=> 'Hu ',
=> Rabbit ',
=> 'Long ',
=> 'Snake ',
=> 'Ma ',
=> 'Yang ',
=> 'Monkey ',
=> 'Chicken ',
=> 'Dog ',
=> 'Pig'
);
// Gender
$ QQ_DATA_SX = array
(
=> 'Male ',
=> Female'
);
Class QQClient
{
Var $ uin;
Var $ pwd;
Var $ server = 'kconn .tencent.com ';
// Standby: 219.133.51.11
Var $ port = 21001;
// Backup: 8000
Var $ httpclient;
Var $ chs = NULL;
Function QQClient ($ uin, $ pwd)
{
$ This-> uin = $ uin;
$ This-> pwd = $ pwd;
}
Function encode ($ str)
/*
Note: Convert the KEY1 = VAL1 & KEY2 = VAL2 format to an array.
*/
{
$ 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 ();
}