Exemple #1
0
        protected override void ProcessResponseText(string responseText)
        {
            WeChatLoginInfo loginInfo = new WeChatLoginInfo();

            loginInfo.Error = responseText;
            WeChatLoginRetInfo retInfo = JSONSerializerExecute.Deserialize <WeChatLoginRetInfo>(responseText);

            retInfo.CheckResult();

            string token = string.Empty;

            if (retInfo.RedirectUrl.Length > 0)
            {
                if (retInfo.RedirectUrl.Contains("ok"))
                {
                    token = retInfo.RedirectUrl.Split(new char[] { '&' })[2].Split(new char[] { '=' })[1].ToString();                    //取得令牌
                    loginInfo.LoginCookie = this.Request.CookieContainer;
                    loginInfo.CreateDate  = SNTPClient.AdjustedTime;
                    loginInfo.Token       = token;

                    CookieCollection cookies = this.Request.CookieContainer.GetCookies(new Uri("https://mp.weixin.qq.com/"));

                    if (cookies["slave_user"] != null)
                    {
                        loginInfo.AccountID = cookies["slave_user"].Value;
                    }
                }
                else
                {
                    throw new ApplicationException(retInfo.ToString());
                }
            }

            WeChatHelper.FillLoginInExtraInfo(loginInfo);

            this.LoginInfo = loginInfo;
        }