Exemple #1
0
        public void GetAccessTokenTest()
        {
            GetAccessTokenResultModel result = BaseApi.GetAccessToken();

            Assert.NotNull(result);
            Assert.NotNull(result.AccessToken);
        }
Exemple #2
0
        public void GetTickectTest()
        {
            GetAccessTokenResultModel result = BaseApi.GetAccessToken();

            Assert.NotNull(result);
            Assert.NotNull(result.AccessToken);

            GetTickectResultModel tickectResult = BaseApi.GetTickect(result.AccessToken);

            Assert.NotNull(tickectResult);
            Assert.NotNull(tickectResult.Ticket);
        }
Exemple #3
0
        /// <summary>
        /// 基础接口 - 获取令牌。
        /// </summary>
        /// <returns>令牌。</returns>
        protected string BaseApiGetAccessToken()
        {
            GetAccessTokenResultModel result = BaseApi.GetAccessToken();

            if (result.ErrorCode == 0)
            {
                WeixinApp.Logger.Info($"TokenServiceBase_GetAccessToken: 当前 Token:{result.AccessToken}");
                return(result.AccessToken);
            }

            string errMsg = $"TokenServiceBase_GetAccessToken: 获取 Token 失败,错误信息:{result.ResponseResultString}";

            WeixinApp.Logger.Fatal(errMsg);
            throw new Exception(errMsg);
        }