本篇主要是: 獲取好友列表,羣列表
javascript
我會盡可能詳細一點,盡我所知的分享一些可能你們已經掌握的或者還不清楚的經驗html
利於你們閱讀,文章樣式再也不復雜化,根據內容取固定色java
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 }
傳入了2個參數:QQ號碼
、ptwebqq(文章2中從cookie中拿到)
c++
http://s.web2.qq.com/api/get_user_friends2
http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1
string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", this.VfWebQQ, this.Hash);
返回json對象由兩部分組成:retcode
、result
,前者表示請求是否成功不提,咱們主要看result,裏面包含了這些東西:web
index
能夠看作分組表的主鍵,sort
排序,name
該組的別名。《個人好友》分組默認是index:0flag
表示默認頭像序號,後文同不提,uin
是貫穿全文的參數,是在網頁關閉前,瀏覽器客戶端的惟一標識,categories
對應上面分組信息nick
,uin
對應惟一標識uin
對應惟一標識,markname
對應備註名稱,這裏要說的是,若是沒有備註,在這裏是不顯示的class JsonFriendModel { public int retcode { get; set; } public paramResult result = new paramResult(); public class paramResult { /// /// 分組信息 /// public List categories = new List(); /// /// 好友彙總 /// public List friends = new List(); /// /// 好友信息 /// public List info = new List(); /// /// 備註 /// public List marknames = new List(); /// /// 分組 /// public class paramCategories { public string index { get; set; } public int sort { get; set; } public string name { get; set; } } /// /// 好友彙總 /// public class paramFriends { public string flag { get; set; } public string uin { get; set; } public string categories { get; set; } } /// /// 好友信息 /// public class paramInfo { public string face { get; set; } public string nick { get; set; } public string uin { get; set; } } /// /// 備註 /// public class paramMarkNames { public string uin { get; set; } public string markname { get; set; } } } }
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 };
以上是使用了left join 多表進行關聯查詢,model即對應了返回json的result屬性算法
http://s.web2.qq.com/api/get_group_name_list_mask2
http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1
string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", this.VfWebQQ, this.Hash);
結構和獲取好友有些相似,不一樣的是:羣的惟一標識是gid,好友的是uin,名稱不一樣。如下是對應的實體類:json
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; } } } }
使用C#模擬http請求能夠參考猛戳這裏c#
您有沒有對這篇文章感興趣呢?api
瀏覽器
本步驟的demo,一步一步來作WebQQ機器人-(四)(獲取好友列表和羣列表+自制QQ分組控件),更新於2015/2/5
能夠到該系列最後一篇文章查看是否可能有最新demo
轉載請保留本頁連接:http://www.cnblogs.com/lianmin/p/4237723.html
.