コード例 #1
0
        private WxUserInfo GetWxUserInfo(string openid)
        {
            WxUserInfo returnResult = null;

            string returnToken    = "";
            string returnUserJson = "";

            string wxAccessToken = WxGetMethod.GetWxAccessToken(ref returnToken);

            if (returnToken.Contains("errcode"))
            {
                //日志记录错误信息


                return(returnResult);
            }

            returnResult = WxGetMethod.GetUserInfo(openid, wxAccessToken, ref returnUserJson);

            if (returnUserJson.Contains("errcode"))
            {
                //手动刷新wxAccessToken
                WxAccToken.SetOverDueTime(DateTime.Now.AddHours(-1));
                wxAccessToken = WxGetMethod.GetWxAccessToken(ref returnToken);

                //再次请求
                returnResult = WxGetMethod.GetUserInfo(openid, wxAccessToken, ref returnUserJson);
                if (returnResult == null || returnUserJson.Contains("errcode"))
                {
                    //日志记录错误信息


                    return(returnResult);
                }
            }

            return(returnResult);
        }
コード例 #2
0
        /// 任何方法的具体实现案例 请参照此文件的最早版本

        public string GetWXToken()
        {
            string json = null;

            return(WxGetMethod.GetWxAccessToken(ref json));
        }