C # implement QQ interface software-QQ's HTTP interface protocol

Source: Internet
Author: User
Document directory
  •  

1. Study 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 am studying the http qq protocol of Version 1.1. The research is based on the results of Weicheng. I dare not say anything beyond it, but it is more detailed and accurate.
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. It is said that 1.2 has come out. 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. uin is the QQ number of the current operation. However, different cmd parameters are required. I will publish my research results below.
3. Research 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 = hackfan (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 = the guy is updating. net frameword ...... & Pv = Jiangsu & Rn = Hu Jiyang & SC = Graduate School & SX = 0 & UN = 106814 & nk = hackfan
Good (normal 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

Related Article

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.