public static void GetTweets(string consumerKey, string consumerSecret) { ConsoleOutput.PrintMessage("Welcome to BoxKite.Twitter Console"); ConsoleOutput.PrintMessage("(control-c ends)"); System.Console.CancelKeyPress += cancelStreamHandler; TwitterCredentials twittercredentials = null; TwitterConnection = new TwitterConnection(consumerKey, consumerSecret); // PIN based authentication var oauth = TwitterConnection.BeginUserAuthentication().Result; // if the response is null, something is wrong with the initial request to OAuth if (!string.IsNullOrWhiteSpace(oauth)) { ConsoleOutput.PrintMessage("Pin: "); var pin = System.Console.ReadLine(); twittercredentials = TwitterConnection.CompleteUserAuthentication(pin, oauth).Result; ManageTwitterCredentials.SaveTwitterCredentialsToFile(twittercredentials); } else { ConsoleOutput.PrintError("Cannot OAuth with Twitter"); } GetTweets(twittercredentials); ConsoleOutput.PrintMessage("All Finished"); System.Console.ReadLine(); }
private static void Main2(string[] args) { ConsoleOutput.PrintMessage("Welcome to BoxKite.Twitter Console (App Auth Tests)"); ConsoleOutput.PrintMessage("(control-c ends)"); System.Console.CancelKeyPress += cancelStreamHandler; twitterConnection = new TwitterConnection("3izxqWiej34yTlofisw", "uncicYQtDx5SoWth1I9xcn5vrpczUct1Oz9ydwTY4"); twitterConnection.StartSearchStreaming("v8sc"); twitterConnection.SearchTimeLine.Subscribe(t => ConsoleOutput.PrintTweet(t)); while (true) { Thread.Sleep(TimeSpan.FromSeconds(0.5)); } }
private static void GetTweets(TwitterCredentials twittercredentials) { if (twittercredentials != null) { TwitterConnection = new TwitterConnection(twittercredentials); TwitterConnection.StartUserStreaming(); ConsoleOutput.PrintMessage(TwitterConnection.TwitterCredentials.ScreenName +" is authorised to use BoxKite.Twitter."); var usersession = TwitterConnection.UserSession; var userstream = TwitterConnection.UserStream; var applicationsession = TwitterConnection.ApplicationSession; new List<Tweet>(); var searchstream = usersession.StartSearchStream(track: "Intel"); searchstream.FoundTweets.Subscribe(ProcessTweet); searchstream.Start(); Thread.Sleep(TimeSpan.FromMinutes(120)); searchstream.CancelStream.Cancel(); searchstream.Stop(); } }