One-step WebQQ robot-(4) (getting friend lists and Group lists) and webqq friend lists
×
This article mainly includes: Get friend list and group list
I will try to be as detailed as possible, and share some experiences that may have been learned or are unclear as far as I know.
For everyone to read, the style of the article is no longer complicated, according to the content of the fixed color
At present, the total progress is about 65%. 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 *)
Get friends
1-obtain the hash algorithm of QQ friends
P = function (b, j) { for (var a = j + "password error", i = "", E = []; ;) if (i.length <= a.length) { if (i += b, i.length == a.length) break; } else { i = i.slice(0, a.length); break } for (var c = 0; c < i.length; c++) E[c] = i.charCodeAt(c) ^ a.charCodeAt(c); a = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; i = ""; for (c = 0; c < E.length; c++) i += a[E[c] >> 4 & 15], i += a[E[c] & 15]; return i }
Two parameters are passed in:QQ number
,Ptwebqq (obtained from cookie in article 2)
Get friends
2-Request
- Address:
http://s.web2.qq.com/api/get_user_friends2
- Referer:
http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1
- Post string:
string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", this.VfWebQQ, this.Hash);
Get friends
3-return and Analysis
The returned json object consists of two parts:retcode
,result
The former indicates whether the request is successful or not. We mainly look at the result, which contains the following:
I have created a class for deserialization.
Class JsonFriendModel {public int retcode {get; set;} public paramResult result = new paramResult (); public class paramResult {// group information // public List categories = new List (); ///// friend summary /// public List friends = new List (); // friend information // public List info = new List (); ///// remarks /// public List marknames = new List (); ////// group /// public class paramCategories {public string index {get; set ;}public int sort {get; set ;}public string name {get; set ;}} ///// friend summary /// public class paramFriends {public string flag {get; set;} public string uin {get; set;} public string categories {get; set ;}///// friends /// public class paramInfo {public string face {get; set;} public string nick {get; set ;} public string uin {get; set ;}///// remarks // public class paramMarkNames {public string uin {get; set ;} public string markname {get; set ;}}}}
Small Scale
Left join query in linqThe result information returned above contains four objects, which are associated with each other using uin or other objects. You can use a for loop. Of course, you can share more beautiful methods with us, if not, please give your comments:
var query = from f in model.result.friends join i in model.result.info on f.uin equals i.uin into table1 from t1 in table1.DefaultIfEmpty() join m in model.result.marknames on f.uin equals m.uin into table2 from t2 in table2.DefaultIfEmpty() select new Friend() { Uin = f.uin, Face = t1 == null ? string.Empty : t1.face, Category = f.categories, Nick = t1 == null ? string.Empty : t1.nick, MarkName = t2 == null ? string.Empty : t2.markname };
The preceding figure uses left join for multi-table join queries. The model corresponds to the result attribute returned in json.
Get Group
1-Request Information
- Address:
http://s.web2.qq.com/api/get_group_name_list_mask2
- Referer:
http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1
- Post string:
string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", this.VfWebQQ, this.Hash);
Get Group
2-return information
The structure is similar to getting friends. The difference is that the unique group ID is gid, the Friends are uin, And the names are different. The following are the corresponding object classes:
class JsonGroupModel { public int retcode { get; set; } public paramResult result = new paramResult(); public class paramResult { public List gnamelist = new List(); public class paramGnamelist { public string flag { get; set; } public string gid { get; set; } public string code { get; set; } public string name { get; set; } } } }
× CloseSo far, you have been able to log on completely and stay online to get messages (the Resolution message is not described yet). To get a list of friends and groups, next I want to write the corresponding demo for each article, to help you better understand the entire process. After all, the article focuses on the process and may encounter one or another problem in actual operations. It may take some time to attach a demo to the previous article. It is even harder to implement the original one per day...
To use C # To simulate http requests, referClick here
Are you interested in this article?
Okay. WQNMLGB
.