/// <summary> /// 返回ClientMsgId /// </summary> /// <returns></returns> public static string GetClientMsgId() { string UnixTimeSpan = DateTimeToosHelper.GetUnixTimeSpan().ToString(); // UnixTimeSpan = UnixTimeSpan.Substring(0, 4) + GetThreeNumber() + new Random().Next(0, 9); return(UnixTimeSpan + GetThreeNumber() + GetThreeNumber() + new Random().Next(0, 9)); }
/// <summary> /// 获取心跳 /// </summary> /// <param name="SyncKey"></param> public static void KeepHeart(string SyncKey) { Random ran = new Random(); string HeartUrl = UrlDefine.HeartUrl + "r=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + MethodsHelper.GetThreeNumber() + "&skey=" + CommonDefine.LoginResult.skey + "&sid=" + CommonDefine.LoginResult.wxsid + "&uin=" + CommonDefine.LoginResult.wxuin + "&deviceid=e9128931905052" + ((int)ran.Next(0, 9)).ToString() + ((int)(ran.Next(0, 8) + 1)).ToString() + "&synckey=" + SyncKey + "&_=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + MethodsHelper.GetThreeNumber(); LogWriter.Write(SyncKey, @"SyncKey.log"); string HeartList = string.Empty; try { HeartList = HttpMethods.Get(HeartUrl, CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString(); } catch (Exception ex) { // HeartList = HttpMethods.Get(HeartUrl, CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString(); } if (!string.IsNullOrWhiteSpace(HeartList)) { LogWriter.Write(HeartList.ToString()); if (HeartList.ToString() != "window.synccheck={retcode:\"0\",selector:\"0\"}") { // Thread.CurrentThread.Abort(); Console.WriteLine(HeartList.ToString()); GetMsg(CommonDefine.SyncKey); CommonDefine.GetMsgSyncKey = GetSyncKey();// 理论上此处不需要赋值,如果收发消息出现问题,放开次注释 } else if (HeartList.ToString() != "window.synccheck={retcode:\"0\",selector:\"7\"}") { // GetMsgSyncKey = GetSyncKey(); } Console.WriteLine(HeartList.ToString()); Console.WriteLine("thK's while is breaked!" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss")); } else { // GetMsgSyncKey = GetSyncKey(); } return; }
/// <summary> /// 获取联系人信息 /// </summary> /// <param name="tickets"></param> /// <param name="skey"></param> /// <returns></returns> public static string GetContactUrl(string tickets, string skey) { return(ContactUrl + tickets + "&r=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + "& seq=0&skey=" + skey); }
public static string HoldOnUrl = "https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=";// + Tickets + "&tip=0&r=1499867820&_=1497443441656"; /// <summary> /// 获取登录地址 /// </summary> /// <param name="uuid"></param> /// <returns></returns> public static string WaitingUrl(string uuid) { return(HoldOnUrl + uuid + "&tip=0&r=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + "& _=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + MethodsHelper.GetThreeNumber()); }