public string GetUserInfo()
        {
            string webToken = HttpContext.Session.GetString("webToken");

            webToken = "22_MJBax-CeFWThD9JlSnaZeMaSwv6wGdeSjr6BrR0Q0mfLObMohgSTV2gAU2kvNq4CzUC5C4BNTqvC2AIzXCRekL08jZgFIR5ADXhaMULAPH8";
            string openid = HttpContext.Session.GetString("Openid");

            openid = "oQ9UN6POP4lSv9rDgaEgmggYdHd8";
            var info = _IweiXinApi.GetUserInfo(webToken, openid, "");

            return(info);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取微信用户信息
        /// </summary>
        /// <param name="access_token">网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同</param>
        /// <param name="openid">用户的唯一标识</param>
        /// <param name="lang">返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语</param>
        /// <returns></returns>
        public static async Task <WeiXinApiResult <UserInfoResult> > GetUserInfoAsync(string access_token, string openid, string lang = "zh_CN")
        {
            var data = await client.GetUserInfo(access_token, openid, lang).Retry(3, TimeSpan.FromSeconds(1))
                       //.WhenResult(item => item == null)
                       .Handle()
                       .WhenCatch <HttpRequestException>(ex =>
            {
                return(WeiXinApiResult <UserInfoResult> .False(ex.HResult, ex.InnerException.Message));
            });

            return(data);
        }