public void UserStreamTest() { OAuthTokens tokens = Configuration.GetTokens(); stream = new TwitterStream(tokens); stream.OnStatusReceived += new TwitterStatusReceivedHandler(stream_OnStatus); stream.OnFriendsReceived += new TwitterFriendsReceivedHandler(stream_OnFriendsReceived); stream.OnStatusDeleted += new TwitterStatusDeletedHandler(stream_OnStatusDeleted); stream.StartUserStream(); for (int i = 0; i < 1000; i++) { System.Threading.Thread.Sleep(100); } stream.EndStream(); }
public void FilterTest() { OAuthTokens tokens = Configuration.GetTokens(); stream = new TwitterStream(tokens); stream.OnStatusReceived += new TwitterStatusReceivedHandler(stream_OnStatus); FilterStreamOptions options = new FilterStreamOptions(); options.Track.Add("twit_er_izer"); options.Track.Add("twitterizer"); stream.StartFilterStream(options); for (int i = 0; i < 1000; i++) { System.Threading.Thread.Sleep(100); } stream.EndStream(); }
public void StartCaptureStreaming(SearchParameters parameters) { StreamOptions options = new StreamOptions(); options.Track.Add(parameters.SearchKey); this._stopSearch = false; TwitterStream stream = new TwitterStream(tokens, "RTSearch (Dev)", options); IAsyncResult result = stream.StartPublicStream( StreamStopped, NewTweet, DeletedTweet, OtherEvent ); while (!this._stopSearch) { } stream.EndStream(StopReasons.StoppedByRequest, "Stop by user"); }
static void Main(string[] args) { Console.BufferWidth = 100; Console.WindowWidth = 100; StreamOptions options = new StreamOptions(); options.Track.Add("#tallycc"); options.Track.Add("tallycc"); options.Track.Add("#tallycodecamp"); options.Track.Add("tallycodecamp"); TwitterStream stream = new TwitterStream( tokens, "Tallahassee CodeCamp2001 Example Application", options); Console.WriteLine("The stream is starting ..."); stream.StartUserStream( StreamInit, StreamStopped, NewTweet, DeletedTweet, NewDirectMessage, DeletedDirectMessage, OtherEvent, RawJson); //optional Console.WriteLine("The stream has started. Press any key to stop."); Console.ReadKey(); Console.WriteLine("Stopping the stream ..."); stream.EndStream(StopReasons.StoppedByRequest, "I'm stopping the stream."); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
/// <summary> /// Stops UserStream. /// </summary> public void StopStreaming() { stream.EndStream(); }
/// <summary> /// Ends the collection of twitter data /// </summary> /// <param name="reason"></param> public void StopCollecting(string reason) { stream.EndStream(StopReasons.StoppedByRequest, reason); }
private void toolStripDropDownButton2_Click(object sender, EventArgs e) { toolStripStatusLabel1.Text = "Restarting..."; ts.EndStream(); timeline.Clear(); if (st == StartType.UserStream) { ts.StartUserStream(null, new StreamStoppedCallback((x) => { toolStripStatusLabel1.Text = "Stopped."; }), new StatusCreatedCallback(x => { Add(x); }), null, null, null, new EventCallback(x => { Event(x); }), null); var tt = TwitterTimeline.HomeTimeline(ts.Tokens); try { foreach (var tss in tt.ResponseObject) { timeline.Add(tss); } toolStripStatusLabel1.Text = "Restarted."; } catch { MessageBox.Show(tt.ErrorMessage); } } else if (st == StartType.FilterStream) { string query = ""; if (ts.StreamOptions.Track.Count != 0) { foreach (string ss in ts.StreamOptions.Track) { query += ss + "+AND+"; } query = query.Remove(query.Length - 5, 5); } ts.StartPublicStream(new StreamStoppedCallback((x) => { toolStripStatusLabel1.Text = "Stopped."; }), new StatusCreatedCallback(x => { Add(x); }), null, new EventCallback(x => { Event(x); })); var tt = TwitterSearch.Search(ts.Tokens, query, new SearchOptions() { ResultType = SearchOptionsResultType.Popular }); try { foreach (var tss in tt.ResponseObject) { timeline.Add(new TwitterStatus() { Text = tss.Text, User = new TwitterUser() { ScreenName = tss.FromUserScreenName } }); } toolStripStatusLabel1.Text = "Restarted."; } catch { MessageBox.Show(tt.ErrorMessage); } } else if (st == StartType.Mentions) { ts.StreamOptions.Track.Add("@" + ExtendedOAuthTokens.Tokens.First <ExtendedOAuthTokens>((x) => { return(x.OAuthTokens == ts.Tokens); }).UserName); ts.StartPublicStream(new StreamStoppedCallback((x) => { toolStripStatusLabel1.Text = "Stopped."; }), new StatusCreatedCallback(x => { Add(x); }), null, new EventCallback(x => { Event(x); })); var tt = TwitterTimeline.Mentions(ts.Tokens); try { foreach (var tss in tt.ResponseObject) { timeline.Add(tss); } toolStripStatusLabel1.Text = "Restarted."; } catch { MessageBox.Show(tt.ErrorMessage); } } ShowF(); }