How to OAuth and use the Filter Query twitter4j Android

223 views Asked by At

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

1

There are 1 answers

0
Ramanan On BEST ANSWER
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