示例#1
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public static bool UserLogin(OAuth_Token model)
        {
            if (model != null)
            {
                // 获取授权信息
                var _authmodel = AuthorizeHelper.GetModelByAuthID(model.openid);
                if (_authmodel == null)
                {
                    // 新用户注册
                    var user = new UserModel()
                    {
                        CreateTime = DateTimeUtility.GetTimeMilliseconds(DateTime.Now),
                        LoginKey   = Guid.NewGuid().ToString(),
                        NickName   = "",
                        UserID     = Guid.NewGuid().ToString()
                    };
                    if (UserHelper.Add(user, new AuthorizeModel()
                    {
                        AuthID = model.openid,
                        Data = SerializeUtility.JavaScriptSerialize(model),
                    }))
                    {
                        return(UserLogin(user));
                    }
                    // 显示添加用户昵称界面:
                    return(false);
                }

                // 获取用户信息
                var _user = UserHelper.GetModelByUserID(_authmodel.UserID);
                return(UserLogin(_user));
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="REFRESH_TOKEN"></param>
        /// <param name="OPENID"></param>
        /// <returns></returns>
        public OAuthUser Get_UserInfo1(string access_token, string openid)
        {
            string    url             = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid + "";
            string    str             = GetJson(url);
            OAuthUser OAuthUser_Model = SerializeUtility.JavaScriptDeserialize <OAuthUser>(str);

            return(OAuthUser_Model);
        }
示例#3
0
        /// <summary>
        /// 获取授权token
        /// </summary>
        /// <param name="Code"></param>
        /// <returns></returns>
        public OAuth_Token Get_token1(string Code)
        {
            string      url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + ConfigSetting.WeiXinAppID + "&secret=" + ConfigSetting.WeiXinAppSecret + "&code=" + Code + "&grant_type=authorization_code ";
            string      str = GetJson(url);
            OAuth_Token Oauth_Token_Model = SerializeUtility.JavaScriptDeserialize <OAuth_Token>(str);

            return(Oauth_Token_Model);
        }