Wednesday, 2 October 2013

Twitter4j Stream not Closing?

Twitter4j Stream not Closing?

I have been searching all over the internet for a way to stop the stream
of tweets from Twitter's Streaming API. I saw this bit of code, but
nothing happens when it is exicuted, and i still get tweets. I have also
tried to set the connection to null, which gave me an error:
Stream.shutdown();
How can i stop this stream? Thanks.
Here is some more of my code:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey("xxxxxxxx").setOAuthConsumerSecret("xxxxxx").setOAuthAccessToken("xxxxxx").setOAuthAccessTokenSecret("xxxxxx");
TwitterStream twitterStream = new
TwitterStreamFactory(cb.build()).getInstance();
After this, i check a boolean to see wheather i should close the stream or
note. If flase, then i do. (sort of swapped around, but false = close
here). Here is that it is eclosed in:
if(!CheckTweets)
{
Stream.shutdown();
}
else
{
// Show Tweets....
}

No comments:

Post a Comment