java - Twitter4j Listen to tweets from a particular user -


I want to do some special work when a particular user tweets something, so from Twitter with a specific user account in 5G Is it possible to listen to tweets and handle the event?

I know what the answer will be: Read the streaming API. But I think this is very huge for my purpose and I only want to hear tweets from a particular account. So I'm asking it here.

You should try a sample code:

  twitterstream twitter stream = New Twitter Stream Provider (new configuration builder.) SetJSONStoreEnabled (true) .build ()). GetInstance (); TwitterStream.setOAuthConsumer (_consumerKey, _consumerSecret); AccessToken Tokens = New AccessToken (_accessToken, _accessTokenSecret); TwitterStream.setOAuthAccessToken (token); StatusListener Listener = New StatusList () {Public status of status (status status) {logger.info (DataObjectFactory.getRawJSON (status)); // do your work here ...}}; TwitterStream.addListener (listener); FilterQuery query = new FilterQuery (); Query.follow (new long [] {_twitterUserId}); TwitterStream.filter (query); }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -