/// <summary> /// 获取好友头像 /// </summary> /// <param name="username"></param> /// <returns></returns> public Image GetIcon(string username) { byte[] bytes = BaseService.SendGetRequest(_geticon_url + username); if (bytes.Length == 0) { return(null); } return(Image.FromStream(new MemoryStream(bytes))); }
private static string _login_check_url = "https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid="; //后面增加会话id /// <summary> /// 获取登录二维码 /// </summary> /// <returns></returns> public Image GetQRCode() { byte[] bytes = BaseService.SendGetRequest(_session_id_url); _session_id = Encoding.UTF8.GetString(bytes).Split(new string[] { "\"" }, StringSplitOptions.None)[1]; bytes = BaseService.SendGetRequest(_qrcode_url + _session_id); string init_str = Encoding.UTF8.GetString(bytes); return(Image.FromStream(new MemoryStream(bytes))); }
/// <summary> /// 微信同步检测 /// </summary> /// <returns></returns> public JObject WxSyncCheck() { string sync_key = ""; List <string> parts = new List <string>(); foreach (KeyValuePair <string, string> p in _syncKey) { parts.Add(p.Key + "_" + p.Value); } sync_key = string.Join("%7C", parts); Cookie sid = BaseService.GetCookie("wxsid"); Cookie uin = BaseService.GetCookie("wxuin"); if (sid != null && uin != null) { log.Debug("sync_key " + sync_key + "\n"); string synccheck_url = string.Format(_synccheck_url, sid.Value, uin.Value, sync_key, (long)(DateTime.Now.ToUniversalTime() - new System.DateTime(1970, 1, 1)).TotalMilliseconds, LoginService.SKey.Replace("@", "%40"), "e1615250492"); log.Debug("synccheck_url " + synccheck_url + "\n"); byte[] bytes = BaseService.SendGetRequest(synccheck_url + "&_=" + DateTime.Now.Ticks); if (bytes != null) { string s = Encoding.UTF8.GetString(bytes); log.Debug("synccheckResponse:\n" + s); s = s.Replace("window.synccheck=", ""); JObject synccheck_resul = JsonConvert.DeserializeObject(s) as JObject; return(synccheck_resul); } else { log.Debug("synccheckResponse is null\n"); return(null); } } else { return(null); } }
/// <summary> /// 微信同步检测 /// </summary> /// <returns></returns> public string WxSyncCheck() { string sync_key = ""; foreach (KeyValuePair <string, string> p in _syncKey) { sync_key += p.Key + "_" + p.Value + "%7C"; } sync_key = sync_key.TrimEnd('%', '7', 'C'); Cookie sid = BaseService.GetCookie("wxsid"); Cookie uin = BaseService.GetCookie("wxuin"); if (LoginService.Url.ToString().IndexOf("2") >= 0) { _synccheck_url = _synccheck_url2; } if (sid != null && uin != null) { _synccheck_url = string.Format(_synccheck_url, sid.Value, uin.Value, sync_key, (long)(DateTime.Now.ToUniversalTime() - new System.DateTime(1970, 1, 1)).TotalMilliseconds, LoginService.SKey.Replace("@", "%40"), "e1615250492"); byte[] bytes = BaseService.SendGetRequest(_synccheck_url + "&_=" + DateTime.Now.Ticks); if (bytes != null) { return(Encoding.UTF8.GetString(bytes)); } else { return(null); } } else { return(null); } }
/// <summary> /// 获取微信讨论组头像 /// </summary> /// <param name="usename"></param> /// <returns></returns> public Image GetHeadImg(string usename) { byte[] bytes = BaseService.SendGetRequest(_getheadimg_url + usename); return(Image.FromStream(new MemoryStream(bytes))); }