/// <summary> /// 检查服务令牌。 /// </summary> /// <returns></returns> public async Task CheckServiceToken() { if (ServiceToken.ExpiredDate > DateTime.Now) { return; } await ServiceToken.RefreshToken(AppId, AppKey); }
/// <summary> /// 实例化服务基类。 /// </summary> /// <param name="serviceToken">服务令牌。</param> /// <param name="appId">公众号Id。</param> /// <param name="appKey">公众号密钥。</param> public ServiceBase(ServiceToken serviceToken, string appId, string appKey) { if (serviceToken == null) { throw new ArgumentNullException("serviceToken"); } if (appId == null) { throw new ArgumentNullException("appId"); } if (appKey == null) { throw new ArgumentNullException("appKey"); } ServiceToken = serviceToken; AppId = appId; AppKey = appKey; }