Ejemplo n.º 1
0
 /// <summary>
 /// 获取头像 默认是个人,获取群组时需要传入URL
 /// </summary>
 /// <param name="username">用户名或群组名</param>
 /// <param name="url">个人或群组URL</param>
 /// <returns></returns>
 public ImageSource GetIcon(string username, string url = StaticUrl.Url_GetIcon)
 {
     byte[] bytes = BaseService.Request(url + username, MethodEnum.GET);
     return(ImageHelper.MemoryToImageSourceOther(new MemoryStream(bytes)));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 登录扫描检测
        /// </summary>
        /// <returns></returns>
        public object LoginCheck()
        {
            if (session_id == null)
            {
                return(null);
            }
            //查看是否扫码登录了
            byte[] bytes = BaseService.Request(StaticUrl.Url_WaitLogin + session_id + "&tip=0&r=" + TimeHelper.GetTimeStamp_TakeBack() + "&_=" + TimeHelper.GetTimeStamp(), MethodEnum.GET);

            string login_result = Encoding.UTF8.GetString(bytes);

            if (login_result.Contains("=" + StaticCode.LoginCode.code_LoginSuccess))
            {
                string login_redirect_url = login_result.Split(new string[] { "\"" }, StringSplitOptions.None)[1];
                string string_url_front   = login_redirect_url.Split(new string[] { "?" }, StringSplitOptions.None)[0];
                if (string_url_front.IndexOf("wx2.qq.com") > -1)
                {
                    StaticUrl.stringWx      = "https://wx2.qq.com";
                    StaticUrl.stringWebPush = "https://webpush2.weixin.qq.com";
                }
                if (string_url_front.IndexOf("wx.qq.com") > -1)
                {
                    StaticUrl.stringWx      = "https://wx.qq.com";
                    StaticUrl.stringWebPush = "https://webpush.weixin.qq.com";
                }
                if (string_url_front.IndexOf("web1.wechat.com") > -1)
                {
                    StaticUrl.stringWx      = "https://web.wechat.com";
                    StaticUrl.stringWebPush = "https://webpush1.wechat.com";
                }
                if (string_url_front.IndexOf("web2.wechat.com") > -1)
                {
                    StaticUrl.stringWx      = "https://web.wechat.com";
                    StaticUrl.stringWebPush = "https://webpush2.wechat.com";
                }
                if (string_url_front.IndexOf("web.wechat.com") > -1)
                {
                    StaticUrl.stringWx      = "https://web.wechat.com";
                    StaticUrl.stringWebPush = "https://webpush.wechat.com";
                }
                if (string_url_front.IndexOf("web1.wechatapp.com") > -1)
                {
                    StaticUrl.stringWx      = "https://web.wechatapp.com";
                    StaticUrl.stringWebPush = "https://webpush1.wechatapp.com";
                }
                if (string_url_front.IndexOf("web.wechatapp.com") > -1)
                {
                    StaticUrl.stringWx      = "https://web.wechatapp.com";
                    StaticUrl.stringWebPush = "https://webpush.wechatapp.com";
                }
                return(login_redirect_url);
            }
            else if (login_result.Contains("=" + StaticCode.LoginCode.code_LoginWait))
            {
                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(ImageHelper.MemoryToImageSource(memoryStream));
            }
            //注:如果用超时的话,会有问题,后期再研究
            //else if (login_result.Contains("=" + StaticCode.LoginCode.code_LoginTimeOut))
            //{
            //    session_id = null;
            //    return 408;
            //}
            else
            {
                return(null);
            }
        }