Step-by-step to do webqq robot-(v) (Send message | | End

Source: Internet
Author: User
Tags urlencode

x

This article is mainly: 发送QQ消息(to:好友,群) , and 对小黄鸡抓包 the use of its language library

This article is the WEBQQ process最后一章

The last chapter is not much, but I am still wordy, probably to most people already know the process method I will also introduce

The first few demo I have uploaded 对应页面的尾部 , the rest will take time to fill, outsourcing often overtime and no outside network, try to 本周 finish

The overall progress is probably 100%The full range is expected to have these steps, of course some of the steps may be merged:
    • Verification Code
    • First time Login
    • Second time landing
    • Stay online and receive messages
    • Get a list of friends and groups
    • Send Message
    • Become intelligent (*?∀?*)
Review the Basics General grasp the way of the mock request

Familiar with the process:

    • Normal operation on the page, familiar with the basic operation process
    • Open the Capture software (Httpwatch,ie9+,ff,chrome), and then to the page operation again, according to the function and request the whole divided into various steps
    • corresponding to each step, multiple operations, understanding each step of the required HTTP request, and constantly simulate each request this step

Precautions:

    • Sensitive pages need to be savedCookie
    • Look for the requested 参数 , this I like to use ie9+, can be searched from the cookie, return body inside. Chrome I didn't find this feature. That is, the parameter may be 来源 a Cookie, or a page, or a return value, etc.
    • of the requestreferer
    • The code cannot find an error after you repeatedly request a domain and then suddenly fail? Give it a try 换个IP
    • Original aim, when you really do not know where there is a problem, to look at the browser, in short, the same as the browser is correct

Tips WEBQQ is unable to get the QQ number of friends

Each friend after you 本次登陆 , will generate a current unique UID code to you, the group is GID, the previous article has introduced the

Before you close the page, you will have to pass this unique code to interact with all your friends and group information. So you need to store your friends ' information in the previous step to identify the message that poll got, where it came from, who said

Send a message also, who do you want to tell, this unique identity is the above uid orgid

Begin Send Message

Chrome is good enough to get you the data before the URL transcoding, and it can help you deserialize the object. IE will only see the string after transcoding.

First, format the data to see:

R: {    "to": 3088776308,    "content": "[\" What are you doing? \ ", [\" font\ ", {\" name\ ": \" arial \ ", \" size\ ": 10,\" style\ ": [0,0,0],\" color\ ": \" 000000\ "}]]",    "face": 585,    " ClientID ": 53999199,    " msg_id ": 38160001,    " Psessionid ":" 8368046764001d636f6e6e7365727665725f77656271714031302e3133332e34312e383400006a5800000425016e0400f36afba86d0000000a404c306 34555727447716d000000287b74805042214d42b7fa4930eb31c8421c1e24bfe90f6b2f35e8221fb3b505f79a85d6b0a97a5252 "} Responseheadersviewsource

All of a sudden a lot of clarity, the main parameters are as follows:

    • To: This time is sent to the friend, here is the friend's UIn
    • The content is the message body and font color style, and the message wrapping in WEBQQ is:\n
    • The face probably enumerates one of the default avatars
    • ClientID is said before, on behalf of an ID, fixed unchanged
    • msg_id here 注意 , it is a 8-digit parameter, and after each message is sent, 都会++ the 自增1 value is used regardless of the friend or group message.
    • Psessionid previously saved QQ token

Then the post string we requested is:

                String postdata = "{\" to\ ":" + UIn                    + ", \" content\ ": \" [\\\ "" + content. Replace (Environment.NewLine, "\\\\n")                    + "\\\", [\\\ "font\\\", {\\\ "name\\\": \\\ "song Body \\\", \\\ "size\\\": 10,\\\ " style\\\ ": [0,0,0],\\\" color\\\ ": \\\" 000000\\\ "}]]\", \ "face\": 549,\ "clientid\": "+ clientid                    +", \ "msg_id\": "+ MsgId                    + ", \" psessionid\ ": \" "+ Psessionid                    +" \ "}";                PostData = "r=" + httputility.urlencode (postdata);

The data in the HTTP request is usually connected by a key value pair "=" , and each key value pair is "&" connected

And will be the value of each key value pair url编码 , you may say, I do not code can use Ah! Of course, most of the site is not a problem, but the browser does do so, try to be consistent with the browser to avoid many errors, such as here.

URL encoding in C # is generally used: HttpUtility.UrlEncode(string) , you need to referenceSystem.Web

    • Referer of the request:http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2
    • Requested URL:http://d.web2.qq.com/channel/send_buddy_msg2
    • Return after successful request: {"retcode":0,"result":"ok"} Note that if your data format is correct, but msg_id is incorrect, it is possible to return this, but the message is not actually sent. TX will expect you to repeat the request, so it returns you a success message.

Sending a group message is similar to this, the only difference being that the post string has a slight change:

                String postdata = "{\" group_uin\ ":" + UIn                    + ", \" content\ ": \" [\\\ "" + content. Replace (Environment.NewLine, "\\\\n")                    + "\\\", [\\\ "font\\\", {\\\ "name\\\": \\\ "song Body \\\", \\\ "size\\\": 10,\\\ " style\\\ ": [0,0,0],\\\" color\\\ ": \\\" 000000\\\ "}]]\", \ "face\": 549,\ "clientid\": "+ clientid                    +", \ "msg_id\": "+ MsgId                    + ", \" psessionid\ ": \" "+ Psessionid                    +" \ "}";                PostData = "r=" + httputility.urlencode (postdata);

xSo far, the WEBQQ simulation request process has been analyzed.

The rest of the chapters of the demo I have been completing this week.

Let's go grab a little yellow chicken and review it and let your WEBQQ project realize the robot function.

I'm the end of the split line

Small yellow Chicken Implementing Robots

I think this picture already contains all of it, and when I see this the first reaction is:

Regardless of whether or not it is used, follow 先访问一下这个页面得到cookie,然后带上这个referer this URL, post this string"para="+HttpUtility.UrlEncode("你在干嘛?")

Of course the above cookie and referer in later my test is useless ...

xClose So far, all the content has been completed

Each section of the demo is complete as soon as possible

Using C # to impersonate an HTTP request can refer to the jab here

Do you have any interest in this article?

It's okay. WQNMLGB

.

Step-by-step to do webqq robot-(v) (Send message | | End)

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.