Example #1
0
 /// <summary>
 /// 获取微信讨论组头像
 /// </summary>
 /// <param name="usename"></param>
 /// <returns></returns>
 public Image GetHeadImg(string usename)
 {
     byte[] bytes = BaseService.SendGetRequest(_getheadimg_url + usename);
     if (bytes == null || bytes.Length == 0)
     {
         return(null);
     }
     return(Image.FromStream(new MemoryStream(bytes)));
 }
Example #2
0
        /// <summary>
        /// 微信同步检测
        /// </summary>
        /// <returns></returns>
        public string WxSyncCheck(Token token)
        {
            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 (sid != null && uin != null)
            {
                List <string> listCheckUrl = new List <string>();
                listCheckUrl.Add("webpush.weixin.qq.com");
                listCheckUrl.Add("webpush2.weixin.qq.com");
                listCheckUrl.Add("webpush.wechat.com");
                listCheckUrl.Add("webpush1.wechat.com");
                listCheckUrl.Add("webpush2.wechat.com");
                listCheckUrl.Add("webpush.wechatapp.com");
                listCheckUrl.Add("webpush1.wechatapp.com");

                byte[] bytes   = null;
                string ret_msg = "";
                foreach (var item in listCheckUrl)
                {
                    string url = "https://" + item + "/cgi-bin/mmwebwx-bin/synccheck?sid={0}&uin={1}&synckey={2}&r={3}&skey={4}&deviceid={5}";
                    _synccheck_url = string.Format(url, sid.Value, uin.Value, sync_key, (long)(DateTime.Now.ToUniversalTime() - new System.DateTime(1970, 1, 1)).TotalMilliseconds, LoginService.SKey.Replace("@", "%40"), "e1615250492");
                    bytes          = BaseService.SendGetRequest(_synccheck_url + "&_=" + DateTime.Now.Ticks);
                    if (bytes != null)
                    {
                        ret_msg = Encoding.UTF8.GetString(bytes);

                        if (ret_msg.Contains("1100") || ret_msg.Contains("1101"))
                        {
                            continue;
                        }
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                return(ret_msg);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 获取好友列表
        /// </summary>
        /// <returns></returns>
        public JObject GetContact()
        {
            List <string> listCheckUrl = new List <string>();

            listCheckUrl.Add("wx.qq.com");
            listCheckUrl.Add("wx2.qq.com");
            byte[] bytes = null;

            foreach (var item in listCheckUrl)
            {
                string r = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString().Split(new char[] { '.' })[0];

                string url = " https://" + item + "/cgi-bin/mmwebwx-bin/webwxgetcontact?" + "r=" + r + "&lang=zh_CN&pass_ticket=" + LoginService.Pass_Ticket;

                bytes = BaseService.SendGetRequest(url);
                if (bytes == null || bytes.Length == 0)
                {
                    continue;
                }
                else
                {
                    if (Encoding.UTF8.GetString(bytes).Contains("\"Ret\": 1"))
                    {
                        continue;
                    }

                    break;
                }
            }

            if (bytes == null)
            {
                foreach (var item in listCheckUrl)
                {
                    string r = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString().Split(new char[] { '.' })[0];

                    string url = " https://" + item + "/cgi-bin/mmwebwx-bin/webwxgetcontact?" + "r=" + r + "&lang=zh_CN&pass_ticket=" + LoginService.Pass_Ticket;

                    bytes = BaseService.SendGetRequest(url);
                    if (bytes == null || bytes.Length == 0)
                    {
                        continue;
                    }
                    else
                    {
                        if (Encoding.UTF8.GetString(bytes).Contains("\"Ret\": 1"))
                        {
                            continue;
                        }

                        break;
                    }
                }
            }
            if (bytes == null)
            {
                return(null);
            }
            string contact_str = Encoding.UTF8.GetString(bytes);

            return(JsonConvert.DeserializeObject(contact_str) as JObject);
        }