Step by step WebQQ robot-(5) (send message | end), webqq Robot

Source: Internet
Author: User

Step by step WebQQ robot-(5) (send message | end), webqq Robot
×

This article mainly includes: Send QQ messages (to: Friends, Group), AndPacket CaptureUse its language library

This document describes the WebQQ process.Last Chapter

The last chapter does not contain much content, but I am still arrogant. I will also introduce the process methods that most people already know.

First fewdemoI have uploadedThe end of the corresponding page, The rest will take time to complete, outsourcing often work overtime and no Internet, tryThis weekComplete

At present, the total progress is about 100%. 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 *)
Review Basics Generally, packet capture simulates requests.

Familiar process:

  • Common Operations on the page, familiar with the basic operation process
  • Open the packet capture software (httpwatch, IE9 +, FF, Chrome) and perform the operations on the page. The steps are divided into various steps based on the functions and requests.
  • For each step and multiple operations, understand the http requests required for each step, and constantly simulate each request.

Note:

  • Sensitive pages need to be savedCookie
  • Find the requestedParametersIn this case, I like to use IE9 +. You can search for it from the cookie and return the body. Chrome does not find this function. That is, the parameter maySourceCookie, page, or returned value, etc.
  • Requestedreferer
  • After simulating a domain for multiple times, the request suddenly fails. Why can't I find the error code?Change IP AddressTry
  • If you really don't know where the problem is, you can check it out with your browser. In short, it's exactly the same as your browser.

 

 

Tips WebQQ cannot obtain the QQ number of a friend.

Every friend is at youThis loginThen, a unique uid code is generated for you. The Group ID is gid, which has been described in the previous article.

Before you close a webpage, you must use this unique code to interact with friends and groups. So in the previous step, you need to store the information of friends to identify the messages obtained by poll.

The same is true for sending messages. The only identifier You Want To Tell isuidOrgid

Start Send message

 

Chrome can help you get the data before url transcoding and deserialize the data into objects. IE can only see the transcoded string.

First, format the data to see:

R: {"to": 3088776308, "content": "[\" what are you doing? \ ", [\" Font \ ", {\" name \ ": \" \ ", \" size \ ": 10, \" style \ ": [0, 0, 0], \ "color \": \ "000000 \"}] "," face ": 585," clientid ": 53999199," msg_id ": 38160001, "psessionid": "response"} ResponseHeadersviewsource

 

All of a sudden, it is much clearer. The main parameters are as follows:

  • To: This is the uin sent to a friend.
  • Content is the message body and font color style. In webqq, the message line feed is:\n
  • A default profile picture enumerated by face
  • Clientid is previously mentioned. It represents an id of the user and is fixed.
  • Msg_id.Note:It is an 8-digit parameter, after each message is sentBoth ++,Auto-increment 1This value is used for both friends and group messages.
  • QQ token saved before psessionid

 

The post string we requested is:

String postData = "{\" to \ ":" + uin + ", \" content \ ": \" [\ "" + content. replace (Environment. newLine, "\\\\ n") + "\\\", [\\\ "font \\\", {\\ "name \\\": \ "\", \ "size \": 10, \ "style \": [0, 0], \ "color \": \ "000000 \"}] \ ", \" face \ ": 549, \" clientid \": "+ ClientID +", \ "msg_id \": "+ MsgId +", \ "psessionid \": \ "" + PSessionID + "\"}"; postData = "r =" + HttpUtility. urlEncode (postData );

 

The data in the Http request."="Connect each key-Value Pair"&"Connect

In addition, the value of each key-value pair isUrl EncodingYou may say that I can also use it without coding! Of course, most websites do not have this problem, but the browser does. Try to be consistent with the browser to avoid many errors, such as here.

In C #, url encoding is generally used:HttpUtility.UrlEncode(string), Need to referenceSystem.Web

 

  • Requested referer:http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2
  • Request url:http://d.web2.qq.com/channel/send_buddy_msg2
  • Return after successful request:{"retcode":0,"result":"ok"},Note:If your data format is correct but msg_id is incorrect, you may also return this message, but the message is not actually sent. TX will give you a success message because you have repeated requests.

 

The send group message is similar to this one. The only difference is that the post string is slightly changed:

String postData = "{\" group_uin \ ":" + uin + ", \" content \ ": \" [\ "" + content. replace (Environment. newLine, "\\\\ n") + "\\\", [\\\ "font \\\", {\\ "name \\\": \ "\", \ "size \": 10, \ "style \": [0, 0], \ "color \": \ "000000 \"}] \ ", \" face \ ": 549, \" clientid \": "+ ClientID +", \ "msg_id \": "+ MsgId +", \ "psessionid \": \ "" + PSessionID + "\"}"; postData = "r =" + HttpUtility. urlEncode (postData );

 

×So far, the webqq simulated request process has been analyzed.

I have completed the remaining demos this week.

Next we will capture the Yellow Chicken and review it. By the way, let your webqq project implement robot functions.

I am the ending split line

Yellow Chicken Implement robots

 

 

I think this image already contains all of them. When I see this, the first response is:

Whether it is used or not,First visit this page to get the cookie, and then bring the refererAccording to the URL, post the string"Para =" + HttpUtility. UrlEncode ("what are you doing? ")

Of course, the cookie and referer above were useless in my tests later...

 

 

 

× CloseSo far, all content has been completed

Complete chapters and Demos as soon as possible

To use C # To simulate http requests, referClick here

Are you interested in this article?

Okay. WQNMLGB

 

 

 

 

 

.

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.