protected void Page_Load(object sender, EventArgs e) { var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); string accessToken = google.RequestNewClientAccount(); ////string tokenSecret = google.TokenManager.GetTokenSecret(accessToken); MessageReceivingEndpoint ep = null; // set up your authorized call here. google.PrepareAuthorizedRequestAndSend(ep, accessToken); }
public static JArray SearchUsers(WebConsumer consumer, String search, string accessToken) { var endpoint = new MessageReceivingEndpoint("http://api.twitter.com/1.1/users/search.json?q=" + search, HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest); IncomingWebResponse response = consumer.PrepareAuthorizedRequestAndSend(endpoint, accessToken); using (var responseReader = response.GetResponseReader()) { var result = responseReader.ReadToEnd(); return JArray.Parse(result); } }
public static JObject GetUserInfo(WebConsumer consumer, int userid, String screenName, string accessToken) { var baseUri = "http://api.twitter.com/1.1/users/show.json"; String uri = String.Empty; if (userid > 0 && String.IsNullOrEmpty(screenName)) uri = String.Concat(baseUri, "?user_id=", userid); if (userid == 0 && !String.IsNullOrEmpty(screenName)) uri = String.Concat(baseUri, "?screen_name=", screenName); var endpoint = new MessageReceivingEndpoint(uri, HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest); IncomingWebResponse response = consumer.PrepareAuthorizedRequestAndSend(endpoint, accessToken); using (var responseReader = response.GetResponseReader()) { var result = responseReader.ReadToEnd(); return JObject.Parse(result); } }