/// <summary> /// Load the detailed account profile /// </summary> /// <param name="account"></param> private void LoadAccountDetailedInfo(QQFriendAccount account) { string getFriendInfoUrl = "http://s.web2.qq.com/api/get_friend_info2?tuin=#{uin}&vfwebqq=#{vfwebqq}&clientid=53999199&psessionid=#{psessionid}&t=#{t}".Replace("#{t}", HTTP.AID_TimeStamp()); getFriendInfoUrl = getFriendInfoUrl.Replace("#{uin}", account.Uin).Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{psessionid}", smartQQ.PSessionId); string retFriendInfo = HTTP.Get(getFriendInfoUrl, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1"); FriendInfo friendInfo = (FriendInfo)JsonConvert.DeserializeObject(retFriendInfo, typeof(FriendInfo)); if (friendInfo.result != null) { account.Blood = friendInfo.result.blood; account.Occupation = friendInfo.result.occupation; account.College = friendInfo.result.college; account.Homepage = friendInfo.result.homepage; account.Country = friendInfo.result.country; account.City = friendInfo.result.city; account.Nick = friendInfo.result.nick; account.Email = friendInfo.result.email; account.Phone = friendInfo.result.phone; account.Mobile = friendInfo.result.mobile; account.Province = friendInfo.result.province; account.Gender = friendInfo.result.gender; if (friendInfo.result.birthday.year != 0 && friendInfo.result.birthday.month != 0 && friendInfo.result.birthday.day != 0) { account.Birthday = new DateTime(friendInfo.result.birthday.year, friendInfo.result.birthday.month, friendInfo.result.birthday.day); } } account.Account = GetQQAccountByUin(account.Uin); }
/// <summary> /// Get QQ Friend List /// </summary> /// <param name="isLoadAccountDetailedInfo">The flag whether or not to load the friend profile</param> /// <returns></returns> public List <QQFriendAccount> GetFriendList(bool isLoadAccountDetailedInfo = false) { string url = "http://s.web2.qq.com/api/get_user_friends2"; string sendData = string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", smartQQ.VFWebQQ, smartQQ.Hash); string dat = HTTP.Post(url, sendData, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1"); Friends friend = (Friends)JsonConvert.DeserializeObject(dat, typeof(Friends)); if (friend.result == null) { return(null); } Dictionary <string, string> MarkNameList = new Dictionary <string, string>(); if (friend.result.markNames != null) { for (int i = 0; i < friend.result.markNames.Count; i++) { MarkNameList.Add(friend.result.markNames[i].uin, friend.result.markNames[i].markname); } } Dictionary <int, string> CategoryList = new Dictionary <int, string>(); if (friend.result.categories != null) { for (int i = 0; i < friend.result.categories.Count; i++) { CategoryList.Add(friend.result.categories[i].index, friend.result.categories[i].name); } } Dictionary <string, QQFriendAccount> accounts = new Dictionary <string, QQFriendAccount>(); string uin = String.Empty; int categoryIndex = -1; string categoryName = String.Empty; if (friend.result.friends != null) { for (int i = 0; i < friend.result.friends.Count; i++) { uin = friend.result.friends[i].uin; QQFriendAccount account = null; if (accounts.ContainsKey(uin)) { account = accounts[uin]; } else { account = new QQFriendAccount(); accounts.Add(uin, account); } account.Uin = uin; account.MarkName = MarkNameList.ContainsKey(uin) ? MarkNameList[uin] : ""; categoryIndex = friend.result.friends[i].categories; account.CategotyIndex = categoryIndex; account.CategotyName = CategoryList.ContainsKey(categoryIndex) ? CategoryList[categoryIndex] : ""; accounts[uin] = account; } } if (friend.result.info != null) { for (int i = 0; i < friend.result.info.Count; i++) { uin = friend.result.info[i].uin; QQFriendAccount account = null; if (accounts.ContainsKey(uin)) { account = accounts[uin]; } else { account = new QQFriendAccount(); accounts.Add(uin, account); } account.Nick = friend.result.info[i].nick; accounts[uin] = account; } } smartQQ.FriendAccounts = accounts.Values.ToList <QQFriendAccount>(); if (isLoadAccountDetailedInfo) { foreach (QQFriendAccount account in smartQQ.FriendAccounts) { LoadAccountDetailedInfo(account); } } return(smartQQ.FriendAccounts); }