Пример #1
0
        /// <summary>
        /// 获取微信用户信息
        /// </summary>
        /// <param name="token"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static WxUserInfo GetWxUserInfo(WxAccessToken token, string code)
        {
            string     url      = "https://api.weixin.qq.com/sns/userinfo?access_token=" + token.access_token + "&openid=" + token.openid;
            WxUserInfo userInfo = JsonHelper.JsonStringToObj <WxUserInfo>(RequestHttp.HttpGet(url));

            return(userInfo);
        }
Пример #2
0
        /// <summary>
        /// 获取用户token
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static WxAccessToken GetToken(string code)
        {
            string url   = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + WxConfig.WxAppId + "&secret=" + WxConfig.WxSecret + "&code=" + code + "&grant_type=authorization_code";
            string value = RequestHttp.HttpGet(url);

            return(JsonHelper.JsonStringToObj <WxAccessToken>(value));
        }
Пример #3
0
        /// <summary>
        /// 获取全局token
        /// </summary>
        /// <returns></returns>
        public static string GetApplicationAccessToken()
        {
            string url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + WxConfig.WxAppId + "&secret=" + WxConfig.WxSecret;

            return(RequestHttp.HttpGet(url));
        }