public static void PerformSearch(OAuthManager oauth, string searchFor) { searchFor = "%40twitterapi"; // now, update twitter status using that access token var appUrl = "https://api.twitter.com/1.1/search/tweets.json?q=" + searchFor; var authzHeader = oauth.GenerateAuthzHeader(appUrl, "POST"); var request = (HttpWebRequest)WebRequest.Create(appUrl); request.Method = "POST"; request.PreAuthenticate = true; request.AllowWriteStreamBuffering = true; request.Headers.Add("Authorization", authzHeader); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { //MessageBox.Show("There's been a problem trying to tweet:" + Environment.NewLine + response.StatusDescription); Console.WriteLine("There's been a problem trying to tweet:" + Environment.NewLine + response.StatusDescription); } } }
/* * // I'll modify this code to perform Twitter Search * var appUrl = "http://api.twitter.com/1/statuses/update.xml?status=Hello"; * var authzHeader = oauth.GenerateAuthzHeader(appUrl, "POST"); * var request = (HttpWebRequest)WebRequest.Create(appUrl); * request.Method = "POST"; * request.PreAuthenticate = true; * request.AllowWriteStreamBuffering = true; * request.Headers.Add("Authorization", authzHeader); * * using (var response = (HttpWebResponse)request.GetResponse()) * { * if (response.StatusCode != HttpStatusCode.OK) * MessageBox.Show("There's been a problem trying to tweet:" + * Environment.NewLine + * response.StatusDescription); * } */ public static void UpdateStatus(OAuthManager oauth, string status) { //var appUrl = "http://api.twitter.com/1/statuses/update.xml?status=Hello"; var appUrl = "http://api.twitter.com/1/statuses/update.xml?status=" + status; appUrl = "https://api.twitter.com/1.1/statuses/update.json?status=Posting%20from%20%40apigee's%20API%20test%20console.%20It's%20like%20a%20command%20line%20for%20the%20Twitter%20API!%20%23apitools&display_coordinates=false"; var authzHeader = oauth.GenerateAuthzHeader(appUrl, "POST"); var request = (HttpWebRequest)WebRequest.Create(appUrl); request.Method = "POST"; request.PreAuthenticate = true; request.AllowWriteStreamBuffering = true; request.Headers.Add("Authorization", authzHeader); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { Console.WriteLine("There's been a problem trying to tweet:" + Environment.NewLine + response.StatusDescription); } } }