HTTP Communication Interface of QQ

Source: Internet
Author: User

1. Description

Tencent has an http qq interface in 8000 of tqq.tencent.com. Through this interface, you can perform some basic operations, such: login, logout, and change login status (online, busy, offline, and invisible) add and delete friends, view friends information, send verification information (accept added as friends, apply to add peer as friends, reject added as friends), send and receive user messages, system information.

At present, I have studied the HTTP QQ protocol of Version 1.1, which is based on the results of others.

2. Interface Description:

Interface location: tqq.tencent.com: 8000
Communication Protocol: HTTP
Data transmission method: POST
HTTP request format:

Posthttp/1.1
Host: tqq.tencent.com: 8000
Content-Type: text/plain; charset = UTF-8
Content-length: length
Connection: close

Data:

The length is the data length. The data format is as follows:
VER = 1.1 & CMD = command & SEQ = Mark & UIN = QQ number &....

The preceding four parameters are mandatory for each request. In this example, VER indicates the Protocol version. Currently, it is 1.1. In this case, the server returns NULL. CMD indicates the operation instruction, there are Login, List, Query_Stat, GetInfo, AddToList, Ack_AddToList, DelFromList, Change_Stat, GetMsgEx, CLTMSG, and Logout. SEQ is the flag of the current request to prevent repeated sending. The current time can be used, you can also use a random number. I use DateTime. now. ticks. toString (). substring (7, 7); UIN is the QQ number of the current operation. However, different CMD parameters are required.

3. Results:

(1). Login
Note: You must log on before you perform any other operations. Other commands can be correctly executed only after Logon (RES = 0 is returned). Otherwise, the server returns RES = 20, but the exception is logout. After you log on to the server, the server will verify your identity based on your IP address * and the UIN parameter. A computer can log on to multiple QQ accounts at the same time, which does not affect each other because of the UIN parameter.
* I can confirm that the server is verified by IP address because the server cannot obtain other information through my request. ^_^

Submit data: VER = 1.1 & CMD = Login & SEQ = Mark & UIN = QQ number & PS = qqpassword & M5 = 1 & LC = 9326B87B234E7235
Note: The QQ password is a string encrypted with md5. in PHP, md5 () can be used for encryption;
The role of the M5 parameter is unknown, but it is better to be 1.
The LC parameter is a bit mysterious and cannot be changed at all. Otherwise, the server will not respond (if there is no response, NULL is returned ).

Return: VER = 1.1 & CMD = LOGIN & SEQ = Mark & UIN = QQ number & RES = 0 & RS = 0 & HI = 60 & LI = 300 (successful)
VER = 1.1 & CMD = LOGIN & SEQ = Mark & UIN = QQ number & RES = 0 & RS = 1 & RA = incorrect password (incorrect password)
VER = 1.1 & CMD = LOGIN & SEQ = Mark & UIN = QQ number & RES = 5 (illegal QQ number, such as 100)
NULL (UIN is a character, PS is NULL, LC error)

(2). Get the friends list
Submit data: VER = 1.1 & CMD = List & SEQ = Mark & UIN = QQ No. & TN = 160 & UN = 0
Note: TN and UN are not clear about the specific representation, but the value of TN will affect the returned results. Is there any UN that has no effect on the results?

Return: VER = 1.1 & CMD = LIST & SEQ = Mark & UIN = QQ number & RES = 0 & FN = 9 (when TN = 0 or there is no TN parameter, FN indicates the number of friends)
VER = 1.1 & CMD = LIST & SEQ = Mark & UIN = QQ number & RES = 0 & FN = 1 & SN = 9 & UN = 3814526 ,..., (If TN exists and is not 0, FN = 1, SN indicates the number of friends, and UN indicates the list of friends, separated)
VER = 1.1 & CMD = LIST & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect login)
NULL (UIN, TN, and UN are characters)

(3). Get the online friends list
Submit data: VER = 1.1 & CMD = Query_Stat & SEQ = Mark & UIN = QQ No. & TN = 50 & UN = 0
Note: TN and UN are not clear about the specific representation, but the value of TN will affect the returned results. Is there any UN that has no effect on the results?

Return: VER = 1.1 & CMD = QUERY_STAT & SEQ = Mark & UIN = QQ number & RES = 0 & FC = 0, & FN = 1 & SN = 1 & ST = 10, & UN = 106814, & NK = Hackfan good, (if TN exists and is not 0, FN = 1, SN indicates the number of online friends, the FC, ST, UN, and NK values are separated by commas (,), indicating the Avatar, status, number, And nickname respectively)
VER = 1.1 & CMD = QUERY_STAT & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect logon)
NULL (UIN, TN, and UN are characters)
Note: FCIS the ID of the QQ image. For example, the ID of the header image is, and the image used by its header is 91.bmp. Its algorithm is ID/3 + 1;
ST is the status of QQ users, 10 is online, 20 is offline (or invisible), and 30 is busy;

Note: When TN = 0 or does not exist, the server returns:
VER = 1.1 & CMD = Query_Stat & SEQ = Mark & UIN = QQ number
HTTP/1.1 200 OK
Server: tencent imserver/1.0.0
Content-Type: text/plain; charset = UTF-8
Content-Length: 56

VER = 1.1 & CMD = QUERY_STAT & SEQ = Mark & UIN = QQ number & RES = 0 & FN = 1
HTTP/1.1 200 OK
Server: tencent imserver/1.0.0
Content-Type: text/plain; charset = UTF-8
Content-Length: 77

VER = 1.1 & CMD = QUERY_STAT & SEQ = Mark & UIN = QQ number & RES = 0 & FC = & FN = 1 & SN = 0 & ST = & UN = & NK =
Two times are returned. In the first result, FN is the number of online friends, and the data returned for the second time is basically useless.

(4). View friend information
Submit data: VER = 1.1 & CMD = GetInfo & SEQ = Mark & UIN = QQ number & LV = Query type & UN = queried QQ number
Note: LV = is a simplified query, LV = 2 is a common query, and LV> = 3 is a detailed query.

Return: VER = 1.1 & CMD = GETINFO & SEQ = Mark & UIN = QQ number & RES = 0 & LV = 0 & UN = 106814 & NK = nickname (simplified query)
VER = 1.1 & CMD = GETINFO & SEQ = Mark & UIN = qqno & RES = 0 & AD = address & AG = 19 & EM = hackfan@qq.com & FC = 0 & HP = http://blog.hackfan.net & JB = student
& LV = 2 & PC = zip code & PH = phone & PR = personal note & PV = Province & RN = Real Name & SC = Graduate School & SX = 0 & UN = 106814 & NK = nickname (Common query)
VER = 1.1 & CMD = GETINFO & SEQ = Mark & UIN = QQ number & RES = 0 & AD = address & AG = 19 & BT = 2 & CO = 6 & CT = Suzhou & CV = % 01 & CY = People's Republic of China
& EM = hackfan@qq.com & FC = 0 & HP = http://blog.hackfan.net & ID =-& JB = student & LV = 3 & MO = 136 * & MT = 0 & MV = & PC = zip code & PH = phone & PR = The guy is
Updating. NET Frameword ...... & PV = Jiangsu & RN = Hu Jiyang & SC = Graduate School & SH = 3 & SX = 0 & UN = 106814 & NK = Hackfan (for details)
VER = 1.1 & CMD = GETINFO & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect logon)
NULL (UIN, LV, and UN are characters)

Note: AD is the contact address.
AG is age
BT is the blood type
CO is a constellation
CT is a city
CV is unknown *
CY is a country
EM is Email
FC is the Avatar
HP is a website
The ID is unknown.
JB is a profession
LV is the query code (that is, the sent LV)
MO is a mobile phone.
MT is unknown
MV is unknown
PC is zip code
PH indicates the contact number.
PR for introduction
PV is saved
RN is the real name
SC is a graduate school
SH is a Chinese zodiac
SX is gender
UN is the QQ number
NK is a nickname

Blood type: 0 => '',
1 => 'A ',
2 => 'B ',
3 => 'o type ',
4 => 'AB type ',
5 => 'others'

Constellation: 0 => '',
1 => 'aquarius ',
2 => 'pisces ',
3 => 'sheepse ',
4 => 'taurus ',
5 => 'gemins ',
6 => 'loan ',
7 => 'Leo ',
8 => 'virgo ',
9 => 'libra ',
10 => 'scorpio ',
11 => 'sagittarius ',
12 => 'capricorn'

Zodiac: 0 => '',
1 => 'rat ',
2 => 'niu ',
3 => 'hu ',
4 => rabbit ',
5 => 'long ',
6 => 'snake ',
7 => 'Ma ',
8 => 'yang ',
9 => 'Monkey ',
10 => 'chicken ',
11 => 'Dog ',
12 => 'pipi'

Gender: 0 => 'male ',
1 => female'

(5). Add friends
Submit data: VER = 1.1 & CMD = AddToList & SEQ = Mark & UIN = QQ number & UN = other party's QQ number

Return: VER = 1.1 & CMD = AddToList & SEQ = Mark & UIN = QQ number & RES = 0 & CD = 0 & UN = QQ number of the other party (can be added as a friend, at this time, he is already your friend)
VER = 1.1 & CMD = AddToList & SEQ = Mark & UIN = QQ number & RES = 0 & CD = 1 & UN = other party's QQ number (verification required)
VER = 1.1 & CMD = AddToList & SEQ = Mark & UIN = QQ number & RES = 0 & CD = 2 & UN = QQ number of the other party (never add as a friend)
VER = 1.1 & CMD = AddToList & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect login)
NULL (UIN and UN are characters)

(5). Send verification
Note: 1. If you add a peer as a friend, you need to send a verification message.
2. The recipient adds you as a friend and sends a verification message. You must pass or reject the verification message.
In both cases, verification messages must be sent.

Submit data: VER = 1.1 & CMD = Ack_AddToList & SEQ = Mark & UIN = QQ number & UN = other party's QQ number & CD = verification type & RS = reason
Note: If the value of CD is 0, it indicates "Verification passed". If the value of CD is 1, it indicates that "the peer is rejected as a friend". If the value of CD is 2, it indicates "adding a friend to the peer ".

Return: VER = 1.1 & CMD = Ack_AddToList & SEQ = Mark & UIN = QQ number & RES = 0 (SUCCESS)
VER = 1.1 & CMD = Ack_AddToList & SEQ = Mark & UIN = QQ number & RES = 3 (*)
VER = 1.1 & CMD = Ack_AddToList & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect logon)
NULL (UIN, UN, CD are characters, RS is not UTF-8 characters)
* If the server returns RES = 3, the response time of this conversation is 20 s. When sending a verification request, the request must be sent twice (the request content does not need to be the same). One of the RES is 3, the other party cannot receive the request, and the other party can receive the request if the request content is 0. When CD> = 3, RES = 3, and response time is 20 s.

(6). Delete friends
Submit data: VER = 1.1 & CMD = DelFromList & SEQ = Mark & UIN = QQ number & UN = deleted QQ number

Return: VER = 1.1 & CMD = DelFromList & SEQ = Mark & UIN = QQ number & RES = 0 & (SUCCESS)
VER = 1.1 & CMD = DelFromList & SEQ = Mark & UIN = QQ number & RES = 3 (Response Time: 30 s, consequences of repeated sending)
VER = 1.1 & CMD = DelFromList & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect logon)
NULL (UIN and UN are characters)

(7). Change the status
Submit data: VER = 1.1 & CMD = Change_Stat & SEQ = Mark & UIN = QQ number & ST = Status Code
Status Code: 10 is online, 20 is offline, 30 is busy, 40 is invisible, and others are regarded as illegal

Return: VER = 1.1 & CMD = Change_Stat & SEQ = Mark & UIN = QQ number & RES = 0 & (SUCCESS)
VER = 1.1 & CMD = Change_Stat & SEQ = Mark & UIN = QQ number & RES = 3 (failed, cause unknown, response time 20 s, may be caused by too frequent status changes)
VER = 1.1 & CMD = Change_Stat & SEQ = Mark & UIN = QQ No. & RES = 20 (incorrect logon)
NULL (UIN is a character, and ST is invalid)

Note: If you change a friend, a system message will be sent to all friends, whose content is the status code. If you are invisible, the status code sent is 20, indicating that you are offline.
Similarly, when your friends change the status, you will also receive a system message.

(9). Get the message
Submit data: VER = 1.1 & CMD = GetMsgEx & SEQ = Mark & UIN = QQ number

Return: VER = 1.1 & CMD = GETMSGEX & SEQ = Mark & UIN = QQ number & RES = 0 & MN = 4 & MT = 99,99, 99,9, & UN = 36791785,99833581, 99833581,106814, & MG = 20, 30, 10, hi, (MN indicates the number of information. The values of MT, UN, and MG are separated by ",", indicating the message type, Sender number, and message content respectively)
VER = 1.1 & CMD = GETMSGEX & SEQ = Mark & UIN = QQ number & RES = 0 & MN = 0 & MT = & UN = & MG = (indicating no information)
VER = 1.1 & CMD = GETMSGEX & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect logon)
NULL (UIN is a character)
Note: About MT:
9 indicates the user message, 99 indicates the system message, 2 indicates the request information, 3 indicates the authentication, and 4 indicates the user is rejected.
About MG:
When MT = 9, MG indicates the message content sent by the user.
When MT = 99,
MG = 10 (QQ_STATUS_ONLINE) indicates that the peer is online.
MG = 20 (QQ_STATUS_OFFLINE) indicates that the other party is offline
MG = 30 (QQ_STATUS_BUSY) indicates that the other party is busy.
When MT = 2, MG is the information the other party requests for your verification
When MT = 3, it indicates that the other party has passed your verification.
When MT = 4, MG rejects you

(10). Send messages
Submit data: VER = 1.1 & CMD = CLTMSG & SEQ = Mark & UIN = QQ number & UN = other party's QQ number & MG = content sent

Return: VER = 1.1 & CMD = CLTMSG & SEQ = Mark & UIN = QQ number & RES = 0 & (if the message is sent successfully, the recipient may not be able to receive the message)
VER = 1.1 & CMD = CLTMSG & SEQ = Mark & UIN = QQ number & RES = 3 (sending too fast)
VER = 1.1 & CMD = CLTMSG & SEQ = Mark & UIN = QQ number & RES = 20 (incorrect login)
NULL (UIN, UN is a character, MG contains non-UTF-8 characters)
Note: 1. When you send a message, the recipient may not be able to see the message in the following cases (in fact, you have received the message and QQ does not prompt:
You two are strangers, and the other party hasn't spoken to you.
You are in his stranger list, and he hasn't spoken to you (not verified)
2. When you send messages too quickly, the system will send you a penalty, RES = 3, corresponding time 20 s
3. When I send a message containing lowercase letter h, the server may return NULL

(11). logout
Submit data: VER = 1.1 & CMD = Logout & SEQ = Mark & UIN = QQ number

Return: VER = 1.1 & CMD = LOGOUT & SEQ = Mark & UIN = QQ number & RES = 0 (successful, it seems to be always successful, whether you log in or not)
NULL (UIN is a character)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.