コード例 #1
0
ファイル: OauthController.cs プロジェクト: Dream2Sky/JCB-Yu
        private UserInfo_JsonModel GetWxUserInfo()
        {
            string code           = CacheManager.GetCache("code").ToString();
            string responseString = string.Empty;

            string url = string.Format(@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx3fab45769c82a189&secret=1b4feb651f6bbae81776068c241f8603&code={0}&grant_type=authorization_code", code);

            responseString = HttpManager.AccessURL_GET(url);
            Access_Token_JsonModel model = new Access_Token_JsonModel();
            UserInfo_JsonModel     user  = new UserInfo_JsonModel();

            try
            {
                model = JsonConvert.DeserializeObject <Access_Token_JsonModel>(responseString);

                LogHelper.Log.Write("access_token:" + model.access_token);

                user = GetUserInfo(model);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Write(ex.Message);
                LogHelper.Log.Write(ex.StackTrace);
                throw;
            }

            return(user);
        }
コード例 #2
0
ファイル: CarController.cs プロジェクト: Dream2Sky/JCB-Yu
        public ActionResult Check(string cookieName, string cookieStr)
        {
            string url    = "http://www.cx580.com/Web/Query.aspx";
            Cookie cookie = new Cookie();

            cookie.Name    = cookieName;
            cookie.Domain  = "www.cx580.com";
            cookie.Path    = "/";
            cookie.Value   = cookieStr;
            cookie.Expires = DateTime.Now.AddDays(1);

            CookieContainer cc = new CookieContainer();

            cc.Add(new Uri(url), cookie);

            string response = HttpManager.AccessURL_GET(url, cc);

            if (response == null)
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }

            Parser parser = new Parser(new Winista.Text.HtmlParser.Lex.Lexer(response));



            return(Json(response, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
ファイル: OauthController.cs プロジェクト: Dream2Sky/JCB-Yu
        /// <summary>
        /// 通过access_token获取用户信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private UserInfo_JsonModel GetUserInfo(Access_Token_JsonModel model)
        {
            string responseString = string.Empty;
            string url            = string.Format(@"https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", model.access_token, model.openid);

            responseString = HttpManager.AccessURL_GET(url);
            LogHelper.Log.Write("打印微信返回的xml");
            LogHelper.Log.Write(responseString);
            UserInfo_JsonModel user = new UserInfo_JsonModel();

            try
            {
                user = JsonConvert.DeserializeObject <UserInfo_JsonModel>(responseString);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Write(ex.Message);
                LogHelper.Log.Write(ex.StackTrace);
                throw;
            }

            return(user);
        }