public OAuthToken GetAccessToken(string scope, string state) { Tools.Helper.HttpHelper Http = new Tools.Helper.HttpHelper("utf-8"); string url = string.Format("{0}token?grant_type=authorization_code&client_id={1}&redirect_uri={2}&state={3}&client_secret={4}&code={5}", new object[] { this.config.GetAuthorizeURL(), this.config.GetAppKey(), this.config.GetCallBackURI().ToString(), state, this.config.GetAppSecret(), scope }); Tools.Helper.HttpHelper.HttpResult hreult = Http.Get(url); if (hreult == null) { return(null); } string accToken = this.GetUserAccessToken(hreult.ResultHtml); if (accToken == "") { return(null); } url = string.Format("https://graph.qq.com/oauth2.0/me?access_token={0}", new object[] { accToken }); hreult = Http.Get(url); if (hreult == null) { return(null); } string openid = this.GetUserOpenId(hreult.ResultHtml); return(new OAuthToken { OpenId = openid, AccessToken = accToken }); }
public string GetHtml(string url) { try { return(httpHelper.Get(url).ResultHtml); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(""); } }