The source of this article http://blog.csdn.net/zhujunxxxxx/if you want to reprint please specify the source!
And then the last article http://blog.csdn.net/zhujunxxxxx/article/details/38931287 me.
All of the above are related to group operations
Next is the way to get your friends ' information
<summary>///Get Friends List information///</summary> public void Getfriendlist () { Dictionary<string, object> r = new dictionary<string, object> (); R.add ("H", "Hello"); R.add ("hash", this.hash); R.add ("Vfwebqq", THIS.VFWEBQQ); dictionary<string, object> data = new dictionary<string, object> (); Data. ADD ("R", Jsonconvert.serializeobject (R)); String postdata = Tool.makepostdata (data); Httpitem item = new Httpitem () {URL = "http://s.web2.qq.com/api/get_user_friends2", Method = "POST", Istolower = false, Timeout = 100000, PostData = PostData , Host = host[1], Referer = referer[1], useragent = "mozilla/5.0 (Windows NT 6.2; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/34.0.1847.116 safari/537.36 ",//user's browser type, version, operating system Available options have default value ContentType = "application/x-www-form-urlencoded", Resulttype = Resulttype.stri NG}; Httpresult result = http. Gethtml (item); jobject ret = (jobject) jsonconvert.deserializeobject (result. Html); Jobject Retjson = (jobject) ret["result"]; Friends with notes foreach (Jtoken jk in retjson["Marknames"]) {this.friendlist.Add (jk["UIn"]. ToString (), jk["Markname"]. ToString ()); }//No memo name for friend foreach (Jtoken jk in retjson["info"]) {if (!this.friendlist. ContainsKey (jk["UIn"). ToString ())) This.friendlist.Add (jk["UIn"]. ToString (), jk["Nick"]. ToString ()); } }
This method can get a friend's information, divided into two parts is a note name of the friend information, part of the friend information without a note name
Save this part of the information to be useful later
Get a specific friend's information (your own information is also obtained through this)
public void Getfriendinfo (String tuin) {string url = "http://s.web2.qq.com/api/get_friend_info2?tuin={ $tuin}&verifysession=&code=&vfwebqq={$vfwebqq}&t=1402534798024 "; url = URL. Replace ("{$vfwebqq}", VFWEBQQ); url = URL. Replace ("{$tuin}", Tuin); Httpitem item = new Httpitem () {url = URL, Encoding = System.Text.Encoding.GetEn Coding ("Utf-8"), Method = "get", Istolower = false, Timeout = 100000, Readwritetimeout = 30000, Host = host[1], Referer = referer[1], UserA Gent = "mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) gecko/20100101 firefox/18.0 ",//user browser type, version, operating system option has default value ContentType =" Application/x-www-fo Rm-urlencoded ", Resulttype = resulttype.string,}; Httpresult result = http. Gethtml (item); }
Next is to send a message to a friend
public void Sendpersonmsg (String tuin,string msg) {string style = "\" {content}\ ""; String temp = ""; Temp + = style. Replace ("{content}", msg) + ","; temp = temp. Substring (0, temp. LENGTH-1); Random rd = new random (); int msg_id = (rd. Next (100000) + 100000); String content = "[{$msg},\" \ ", [\" font\ ", {\" name\ ": \" arial \ ", \" size\ ": \" 10\ ", \" style\ ": [0,0,0],\" color\ ": \" 000000\ "} ]]"; Content = content. Replace ("{$msg}", temp); Dictionary<string, object> r = new dictionary<string, object> (); R.add ("to", Tuin); R.add ("Face", 561); R.add ("content", content); R.add ("msg_id", msg_id); R.add ("ClientID", This.clientid); R.add ("Psessionid", This.psessionid); dictionary<string, object> data = new dictionary<string, object> (); Data. ADD ("R", Jsonconvert.serializeobject (R)); Data. ADD ("ClientID", This.clientid); Data. ADD ("Psessionid", This.psessionid); String postdata = Tool.makepostdata (data); Httpitem item = new Httpitem () {URL = "http://d.web2.qq.com/channel/send_buddy_msg2", Accept = "*/*", Method = "POST", Istolower = False, KeepAlive = True, Timeout = 100000, PostData = postdata, Host = host[0], Referer = Referer[0], useragent = "mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/37.0.2041.4 safari/537.36 ", ContentType =" Application /x-www-form-urlencoded ", Resulttype = resulttype.string}; Httpresult result = http. Gethtml (item); jobject ret = (jobject) jsonconvert.deserializeobject (result. Html); }
Well, this and the previous article basically realized the basic function of WEBQQ,
In order to keep QQ online For example, we send a heartbeat request to the server for a certain time, and the return value of the heartbeat request is the message we received, which is important so we need to deal with the group message.
public void Heartbreak () {/* dictionary<string, object> r = new Dictionary<string, Object> (); R.add ("ClientID", This.clientid); R.add ("Psessionid", This.psessionid); R.add ("key", 0); R.add ("IDs", "[]"); dictionary<string, object> data = new dictionary<string, object> (); Data. ADD ("R", Jsonconvert.serializeobject (R)); Data. ADD ("ClientID", This.clientid); Data. ADD ("Psessionid", This.psessionid); String postdata2 = Tool.makepostdata (data); */String postdata = "r=%7b%22clientid%22%3a%22{$clientid}%22%2c%22psessionid%22%3a%22{$psessionid}%22%2c%22key %22%3a0%2c%22ids%22%3a%5b%5d%7d&clientid={$clientid}&psessionid={$psessionid} "; Postdata=postdata. Replace ("{$clientid}", This.clientid); PostData = PostData. Replace ("{$psessionid}", This.psessionid); Httpitem item = new Httpitem () {URL = "http://d.web2.qq.com/channel/poll2", Method = "POST", Istol Ower = False, Timeout = 100000, PostData = postdata, Host = Host[0], Referer = Referer[0], useragent = "mozilla/5.0 (Windows NT 6.2; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/34.0.1847.116 safari/537.36 ",//user's browser type, version, operating system option has default value ContentType = "application/x-www-form-urlencoded", Resulttype = resulttype.string}; Httpresult result = http. Gethtml (item); jobject ret = (jobject) jsonconvert.deserializeobject (result. Html); Jobject Retjson = (jobject) ret["result"][0]; if (retjson["Poll_type"]. ToString () = = "Group_message") {jobject msg = (jobject) retjson["value"]; Processmsg (msg); } thread.sleep (2000); }
On the top of the message there are some can be expanded, than the film, and I have not studied this part, if anyone has done so, want to share it?
C # WEBQQ Protocol mass Robot (II)