Esempio n. 1
0
        /// <summary>
        /// 根据用户Code获取用户信息(包括OpenId的简单信息)
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static WeiXinUserSampleInfo GetnxcUserSampleInfo(string code)
        {
            string url = string.Format(WeiXinConst.WeiXin_User_OpenIdUrl,
                                       System.Configuration.ConfigurationManager.AppSettings["appid"],
                                       System.Configuration.ConfigurationManager.AppSettings["secret"], code);
            WeiXinUserSampleInfo info = HttpClientHelper.GetResponse <WeiXinUserSampleInfo>(url);

            return(info);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据用户Code获取用户信息(包括OpenId的简单信息)
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static WeiXinUserSampleInfo GetUserSampleInfo(string code)
        {
            string url = string.Format(WeiXinConst.WeiXin_User_OpenIdUrl, code);
            WeiXinUserSampleInfo info = HttpClientHelper.GetResponse <WeiXinUserSampleInfo>(url);

            try
            {
                HttpContext.Current.Session["openid"] = info.OpenId;
                //HttpCookie txtcookie = new HttpCookie("openid", info.OpenId);
                //DateTime dt = new DateTime();
                //dt = DateTime.Now;
                //TimeSpan ts = new TimeSpan(0, 1, 1, 0);
                //txtcookie.Expires = dt.Add(ts);
                //HttpContext.Current.Response.SetCookie(txtcookie);
                //LogApp.Log4Net.Info("cookie:" + HttpContext.Current.Request.Cookies["openid"]);
                LogApp.Log4Net.Info("openid3:" + HttpContext.Current.Session["openid"]);
            }
            catch (Exception ex)
            {
                LogApp.Log4Net.Info("ex:" + ex);
            }
            return(info);
        }