Ejemplo n.º 1
0
        public ResultModel <AccessTokenModel> GetBaseAccessTokenData()
        {
            var url = string.Format(WrapConfig.BaseAccessTokenUrl, BasicConfig.WeChat_AppId, BasicConfig.WeChat_Secret);

            var jsonResult = WHttpUtil.HttpGet(url);

            if (!string.IsNullOrWhiteSpace(jsonResult))
            {
                var result = JsonConvert.DeserializeObject <AccessTokenModel>(jsonResult);

                if (result == null)
                {
                    return(new ResultModel <AccessTokenModel>
                    {
                        code = 0,
                        msg = jsonResult,
                        data = null
                    });
                }

                return(new ResultModel <AccessTokenModel>
                {
                    code = 1,
                    msg = jsonResult,
                    data = result
                });
            }

            return(null);
        }
Ejemplo n.º 2
0
        public ResultModel <PcAccessTokenModel> GetPcAccessTokenData(string code, string appid, string secret)
        {
            var url = string.Format(WrapConfig.PcAccessTokenUrl, appid, secret, code);

            var jsonResult = WHttpUtil.HttpGet(url);

            if (!string.IsNullOrWhiteSpace(jsonResult))
            {
                var result = JsonConvert.DeserializeObject <PcAccessTokenModel>(jsonResult);

                if (result == null)
                {
                    return(new ResultModel <PcAccessTokenModel>
                    {
                        code = 0,
                        msg = jsonResult,
                        data = null
                    });
                }

                return(new ResultModel <PcAccessTokenModel>
                {
                    code = 1,
                    msg = jsonResult,
                    data = result
                });
            }

            return(null);
        }
Ejemplo n.º 3
0
        public ResultModel <UserInfoModel> GetUser_InfoData(string accesstoken, string openid)
        {
            var url        = string.Format(WrapConfig.User_InfoUrl, accesstoken, openid);
            var jsonResult = WHttpUtil.HttpGet(url);

            if (!string.IsNullOrWhiteSpace(jsonResult))
            {
                var result = JsonConvert.DeserializeObject <UserInfoModel>(jsonResult);
                if (result == null || !string.IsNullOrWhiteSpace(result.errcode))
                {
                    return(new ResultModel <UserInfoModel>
                    {
                        code = 0,
                        msg = jsonResult,
                        data = null
                    });
                }
                return(new ResultModel <UserInfoModel>
                {
                    code = 1,
                    msg = jsonResult,
                    data = result
                });
            }
            return(null);
        }