/// <summary> /// 心跳 /// </summary> public void FeartBeat() { while (jieshu) { string uri = heartbeat + "qq.com/cgi-bin/mmwebwx-bin/synccheck?r=" + function.MilliTime() + "&skey=" + skey + "&sid=" + wxsid.Replace("+", "%2B") + "&uin=" + wxuin + "&deviceid=" + DeviceID() + "&synckey=" + SkeyGet + "&_=" + tim.ToString(); tim++; string s = HttpHelps.GetQrh(uri, webwx_data_ticket); /*string retcode = function.middlestring(s, "retcode:\"", "\""); * string selector = function.middlestring(s, "selector:\"", "\""); * * if (retcode == "0") * { * if (int.Parse(selector) > 0) * { * //消息获取 * BeingPushed(retcode, selector); * } * }*/ Thread.Sleep(1000); } }
/// <summary> /// 好友列表 /// </summary> public void FriendsList(bool b) { friends = new DataTable(); friends.Columns.Add("UserName"); friends.Columns.Add("NickName"); friends.Columns.Add("HeadImgUrl"); friends.Columns.Add("RemarkName"); string uri = domain + "/cgi-bin/mmwebwx-bin/webwxgetcontact?&pass_ticket=" + pass_ticket + "&r=" + function.MilliTime() + "&seq=0&skey=" + skey; uri = uri.Replace("http", "https"); while (true) { string s = HttpHelps.GetQrh(uri, cookie); //删减无用HTML while (true) { string ls = function.middlestring(s, "<span", "</span>"); if (ls != "") { s = s.Replace("<span" + ls + "</span>", ""); } else { break; } } Friends = JObject.Parse(s); JToken record = Friends["MemberList"]; //循环加载好友 Group = new List <string>(); foreach (JObject jp in record) { if (jp["VerifyFlag"].ToString() == "0") { DataRow dr = friends.NewRow(); dr[0] = jp["UserName"]; dr[1] = jp["NickName"]; dr[2] = jp["HeadImgUrl"]; dr[3] = jp["RemarkName"]; friends.Rows.Add(dr); //头像获取 //Image HeadImage =new Bitmap(HttpHelps.GetPicture(domain + jp["HeadImgUrl"].ToString(), cookie)); //这里往控件加载头像和好友信息 } if (jp["UserName"].ToString().IndexOf("@@") != -1) { Group.Add(jp["UserName"].ToString()); } } if (function.middlestring(s, "Seq\": ", "\n}") == "0") { break; } else { uri = uri.Replace("seq=" + function.middlestring(uri, "seq=", "&") + "&", "seq=" + function.middlestring(s, "Seq\": ", "\n}") + "&"); } } GETgroup(); //数据回调函数 if (jzhy != null) { jzhy(friends); } if (!b) { return; } //单线程启动心跳 var thread = new Thread(FeartBeat); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); var th = new Thread(xh); th.SetApartmentState(ApartmentState.STA); th.IsBackground = true; th.Start(); }