/// <summary> /// 刷新访问票据。 /// </summary> /// <param name="refreshToken">刷新票据。</param> /// <returns>结果模型。</returns> public GetOAuthAccessTokenResult RefreshToken(string refreshToken) { var url = _openAccountModel == null?string.Format("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1}", _accountModel.AppId, refreshToken) : string.Format("https://api.weixin.qq.com/sns/oauth2/component/refresh_token?appid={0}&grant_type=refresh_token&component_appid={1}&component_access_token={2}&refresh_token={3}", _accountModel.AppId, _openAccountModel.AppId, _openAccountModel.GetAccessToken(), refreshToken); return(GetOAuthAccessTokenResult.CreateResult(WeiXinHttpHelper.GetString(url))); }
/// <summary> /// 获取访问票据。 /// </summary> /// <param name="code">公众平台Code参数。</param> /// <returns>结果模型。</returns> public GetOAuthAccessTokenResult GetAccessToken(string code) { var url = _openAccountModel != null?string.Format("https://api.weixin.qq.com/sns/oauth2/component/access_token?appid={0}&code={1}&grant_type=authorization_code&component_appid={2}&component_access_token={3}", _accountModel.AppId, code, _openAccountModel.AppId, _openAccountModel.GetAccessToken()) : string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", _accountModel.AppId, _accountModel.AppSecret, code); return(GetOAuthAccessTokenResult.CreateResult(WeiXinHttpHelper.GetString(url))); }