简体   繁体   中英

How to OAuth and use the Filter Query twitter4j Android

Basically I want to search for a query in the live stream of tweets (but i only want to know how many tweets are received within a time period) with the twitter based Twitter4j in Android say:

FilterQuery query = new FilterQuery();
String[] keywordsArray = { "python", "java", "scala" };
query.track(keywordsArray);

But how to authenticate using oauth and what url are to be called to perform these actions? And is there a way to save the stream of tweets into an arraylist only to find it's .length? Thanks In advance

ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("*************");
cb.setOAuthConsumerSecret("*************");
cb.setOAuthAccessToken("*************");
cb.setOAuthAccessTokenSecret("*************");

TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

Full example: http://davidcrowley.me/?p=435

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM