コード例 #1
0
        /// <summary>
        /// 登录扫描检测
        /// </summary>
        /// <returns></returns>
        public object LoginCheck()
        {
            if (_session_id == null)
            {
                return(null);
            }
            byte[] bytes        = BaseService2.SendGetRequest(_login_check_url + _session_id);
            string login_result = Encoding.UTF8.GetString(bytes);

            if (login_result.Contains("=201")) //已扫描 未登录
            {
                string       base64_image       = login_result.Split(new string[] { "\'" }, StringSplitOptions.None)[1].Split(',')[1];
                byte[]       base64_image_bytes = Convert.FromBase64String(base64_image);
                MemoryStream memoryStream       = new MemoryStream(base64_image_bytes, 0, base64_image_bytes.Length);
                memoryStream.Write(base64_image_bytes, 0, base64_image_bytes.Length);
                //转成图片
                return(Image.FromStream(memoryStream));
            }
            else if (login_result.Contains("=200"))  //已扫描 已登录
            {
                string login_redirect_url = login_result.Split(new string[] { "\"" }, StringSplitOptions.None)[1];
                return(login_redirect_url);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        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 = BaseService2.SendGetRequest(_session_id_url);
            _session_id = Encoding.UTF8.GetString(bytes).Split(new string[] { "\"" }, StringSplitOptions.None)[1];
            bytes       = BaseService2.SendGetRequest(_qrcode_url + _session_id);

            return(Image.FromStream(new MemoryStream(bytes)));
        }
コード例 #3
0
 /// <summary>
 /// 获取微信讨论组头像
 /// </summary>
 /// <param name="usename"></param>
 /// <returns></returns>
 public Image GetHeadImg(string usename)
 {
     byte[] bytes = BaseService2.SendGetRequest(_getheadimg_url + usename);
     if (bytes == null || bytes.Length == 0)
     {
         return(null);
     }
     return(Image.FromStream(new MemoryStream(bytes)));
 }
コード例 #4
0
        /// <summary>
        /// 获取好友列表
        /// </summary>
        /// <returns></returns>
        public JObject GetContact()
        {
            byte[] bytes = BaseService2.SendGetRequest(_getcontact_url);
            if (bytes == null || bytes.Length == 0)
            {
                return(null);
            }
            string contact_str = Encoding.UTF8.GetString(bytes);

            return(JsonConvert.DeserializeObject(contact_str) as JObject);
        }
コード例 #5
0
        /// <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 = BaseService2.GetCookie("wxsid");
            Cookie uin = BaseService2.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, LoginService2.SKey.Replace("@", "%40"), "e1615250492");
                    bytes          = BaseService2.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);
            }
        }
コード例 #6
0
        /// <summary>
        /// 获取sid uid   结果存放在cookies中
        /// </summary>
        public void GetSidUid(string login_redirect)
        {
            byte[] bytes = BaseService2.SendGetRequest(login_redirect + "&fun=new&version=v2&lang=zh_CN");
            if (bytes == null || bytes.Length == 0)
            {
                return;
            }
            string pass_ticket = Encoding.UTF8.GetString(bytes);

            Pass_Ticket = pass_ticket.Split(new string[] { "pass_ticket" }, StringSplitOptions.None)[1].TrimStart('>').TrimEnd('<', '/');
            SKey        = pass_ticket.Split(new string[] { "skey" }, StringSplitOptions.None)[1].TrimStart('>').TrimEnd('<', '/');
        }