/// <summary> /// 批量获取联系人详细信息 /// </summary> /// <param name="requestContacts"></param> /// <param name="pass_ticket"></param> /// <param name="uin"></param> /// <param name="sid"></param> /// <param name="skey"></param> /// <param name="deviceID"></param> /// <returns></returns> public BatchGetContactResponse BatchGetContact(string[] requestContacts, string pass_ticket, BaseRequest baseReq) { string url = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r={0}&lang=zh_CN&pass_ticket={1}"; url = string.Format(url, getTimestamp(DateTime.Now), pass_ticket); BatchGetContactRequest req = new BatchGetContactRequest(); req.BaseRequest = baseReq; req.Count = requestContacts.Length; List <BatchUser> requestUsers = new List <BatchUser>(); for (int i = 0; i < req.Count; i++) { var tmp = new BatchUser(); tmp.UserName = requestContacts[i]; requestUsers.Add(tmp); } req.List = requestUsers.ToArray(); string requestJson = JsonConvert.SerializeObject(req); string repJsonStr = http.POST_UTF8String(url, requestJson); var rep = JsonConvert.DeserializeObject <BatchGetContactResponse>(repJsonStr); return(rep); }
/// <summary> /// 批量获取联系人详细信息 /// </summary> /// <param name="requestContacts"></param> /// <param name="pass_ticket"></param> /// <param name="uin"></param> /// <param name="sid"></param> /// <param name="skey"></param> /// <param name="deviceID"></param> public void BatchGetContact(string[] requestContacts, string pass_ticket, BaseRequest baseReq, Action <BatchGetContactResponse> CallBack) { BatchGetContactRequest req = new BatchGetContactRequest { BaseRequest = baseReq, Count = requestContacts.Length }; List <BatchUser> requestUsers = new List <BatchUser>(); for (int i = 0; i < req.Count; i++) { var tmp = new BatchUser { UserName = requestContacts[i], }; requestUsers.Add(tmp); } req.List = requestUsers.ToArray(); string requestJson = JsonConvert.SerializeObject(req); string url = "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r={0}&lang=zh_CN&pass_ticket={1}"; url = string.Format(url, GetR(), pass_ticket); http.Item.Request.HeadersDic["Accept"] = "application/json, text/plain, */*"; http.GetHtml(url, "post", requestJson, referer: "https://wx2.qq.com/", callBack: (x) => { string repJsonStr = x.response.DataString(); var rep = JsonConvert.DeserializeObject <BatchGetContactResponse>(repJsonStr); CallBack?.Invoke(rep); }); }
/// <summary> /// 批量获取联系人详细信息 /// </summary> /// <param name="requestContacts"></param> /// <param name="pass_ticket"></param> /// <param name="uin"></param> /// <param name="sid"></param> /// <param name="skey"></param> /// <param name="deviceID"></param> /// <returns></returns> public BatchGetContactResponse BatchGetContact(string[] requestContacts, string pass_ticket, BaseRequest baseReq) { SetHttpHeader("Accept", "application/json, text/plain, */*"); SetHttpHeader("Connection", "keep-alive"); SetHttpHeader("Accept-Encoding", "gzip, deflate, br"); string url = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r={0}&lang=zh_CN&pass_ticket={1}"; url = string.Format(url, getR(), pass_ticket); BatchGetContactRequest req = new BatchGetContactRequest(); req.BaseRequest = baseReq; req.Count = requestContacts.Length; List <BatchUser> requestUsers = new List <BatchUser>(); for (int i = 0; i < req.Count; i++) { var tmp = new BatchUser(); tmp.UserName = requestContacts[i]; requestUsers.Add(tmp); } req.List = requestUsers.ToArray(); string requestJson = JsonConvert.SerializeObject(req); string repJsonStr = PostString(url, requestJson); var rep = JsonConvert.DeserializeObject <BatchGetContactResponse>(repJsonStr); if (rep == null) { return(null); } return(rep); }