Step by step WebQQ robots-(3) (log on to QQ and stay online), webqq robots
×
The purpose of this article isLet your QQ go online:Squeeze your PCQQ, AndShow webqq online to the status bar of friends
At present, the total progress is about 50%. These steps are expected in the full series. Of course, some steps may be merged:
- Verification Code
- First Login
- Second Login
- Keep online and receive messages
- Get friends and Group lists
- Send message
- Turn to intelligent (* artificial intelligence *)
Second Login
Real online,Squeeze PCQQ,WebQQ online statusFirst look at this request
Request Message analysis
- Referer is indispensable. First, tell the TX server that the request comes from here:
http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2
- Post Data is in json format:
string.Format("r={{\"ptwebqq\":\"{0}\",\"clientid\":{1},\"psessionid\":\"\",\"status\":\"online\"}}", this.PtWebQQ, this.ClientID);
Ptwebqq is the value obtained from the cookie in the previous article. Do not remember to go back and check it...
Clientid is an 8-length number, for example:29528322It is used as the unique identifier of a user and can be defined as a constant.
Return Value:
Retcode: 0, indicating success
Note:In the result propertypsessionidAndvfwebqqIt is the QQ token for your login. It is the basis for successful login and must be saved.
Here you will find that PCQQ notifies you that your QQ is logged on elsewhere and you are forced to go offline. I'm very happy with youmu)
But you will soon find that your webqq will be disconnected in half a minute.
POLL
Keep online + get friends and group messages
Request description:
Request address:http://d.web2.qq.com/channel/poll2
Referer:http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2
POST parameters:r:{"ptwebqq":"XXXX","clientid":XXXXX,"psessionid":"XXXXXX","key":""}
The preceding parameters have been saved in the previous operation.
This isPollThe browser uses ajax to send a long timeout to the server. When the server has your new message, the message is returned to you, or an empty message is sent to you after a long wait.
The server knows that you are still trying to get new messages, and you will understand that you are still online, that is, keepOnline status.
The message returned by this request isFriend messageOrGroup message
Realize a problem:
I tried to follow the process step by step. Now I suddenly thought that parsing the returned message depends on obtaining the friends list and Q group list.
Therefore, I will temporarily delay the resolution.
× CloseSo far, you have been able to log on completely and stay online. The next article will analyze the list of friends and Q groups and introduce some extensions.
To use C # To simulate http requests, referClick here
Are you interested in this article?
Okay. WQNMLGB
.