本篇主要是: 獲取好友列表,群列表
我會盡量詳細一點,盡我所知的分享一些可能大家已經掌握的或者還不清楚的經驗
利於大家閱讀,文章樣式不再復雜化,根據內容取固定色
目前總進度大概65%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中拿到)
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,裡面包含了這些東西:
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,名稱不同。以下是對應的實體類:
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請求可以參考猛戳這裡
您有沒有對這篇文章感興趣呢?
.