static void Main(string[] args) { // create a string with your credentials // if you provide an encrypted password, set the flag TwitterStream stream = new TwitterStream (user, pass, isEncrypted); /* // Optional: Add a filter. If filtering, // the Twitter API requires to specify at least 1 parameter TwitterStreamFilter filter = new TwitterStreamFilter (); string[] keywords = { "twitter", "pizza"}; filter.setTrackingKeywords (keywords); // to remove the filter, set it to null stream.SetStreamFilter (filter); */ stream.StartAsyncStream (); while (stream.IsStreamRunning() && (numberOfTweets != 0)) { Status status = stream.GetBlockingNextStatus (); // make sure to handle deleted statuses which appear in // public stream if (status.text != null) { Console.Write ("@" + status.user.screen_name + ": "); Console.WriteLine (status.text); numberOfTweets--; } } // make sure to clean up stream.StopAsyncStream (); }
static void Main(string[] args) { TwitterStream stream = new TwitterStream(); Logger logger = new Logger(); string arg1 = ""; try { if (args.Length > 0) { arg1 = args[0]; } switch (arg1) { case "/?": Console.WriteLine("Twitter Stream Client.\n"); Console.WriteLine("twitterstreamclient [/p]\n"); Console.WriteLine("[]\t\t\tProcess the Twitter Stream to a Message Queue."); Console.WriteLine("/p\t\t\tProcess the Message Queue."); Console.WriteLine("/encrypt password\tEncrypt a Twitter password for the config file.\n"); Console.WriteLine("\nPress any key to continue . . ."); Console.ReadKey(); break; case "/encrypt": if (args.Length > 1) { Console.WriteLine(Common.Encrypt(args[1])); } break; case "/p": stream.QueueRead(); break; default: stream.Stream2Queue(); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.append(ex.Message, Logger.LogLevel.ERROR); } }
static void Main(string[] args) { TwitterStream stream = new TwitterStream(); Logger logger = new Logger(); string arg1 = ""; try { if (args.Length > 0) { arg1 = args[0]; } switch (arg1) { case "/?": Console.WriteLine("Twitter Stream Client.\n"); Console.WriteLine("twitterstreamclient [/p]\n"); Console.WriteLine("[]\t\t\tProcess the Twitter Stream to a Message Queue."); Console.WriteLine("/p\t\t\tProcess the Message Queue."); Console.WriteLine("/encrypt password\tEncrypt a Twitter password for the config file.\n"); Console.WriteLine("\nPress any key to continue . . ."); Console.ReadKey(); break; case "/encrypt": if (args.Length > 1) { Console.WriteLine(Common.Encrypt(args[1])); } break; case "/p": stream.QueueRead(); break; default: //stream.Stream2Queue(); KeywordCounter kc = new KeywordCounter(); kc.GetSearchCount("karachi", DateTime.Now); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.append(ex.Message, Logger.LogLevel.ERROR); } }
static void Main(string[] args) { // create a string with your credentials // if you provide an encrypted password, set the flag TwitterStream stream = new TwitterStream(user, pass, isEncrypted); /* * // Optional: Add a filter. If filtering, * // the Twitter API requires to specify at least 1 parameter * TwitterStreamFilter filter = new TwitterStreamFilter (); * string[] keywords = { "twitter", "pizza"}; * filter.setTrackingKeywords (keywords); * // to remove the filter, set it to null * stream.SetStreamFilter (filter); */ stream.StartAsyncStream(); while (stream.IsStreamRunning() && (numberOfTweets != 0)) { Status status = stream.GetBlockingNextStatus(); // make sure to handle deleted statuses which appear in // public stream if (status.text != null) { Console.Write("@" + status.user.screen_name + ": "); Console.WriteLine(status.text); numberOfTweets--; } } // make sure to clean up stream.StopAsyncStream(); }