Reputation: 115
How to search for multiple twitter ids in one request using twitter4j library. Even using in clause in Search parameter would be helpful. Please help!
Upvotes: 2
Views: 561
Reputation: 1301
Please find some sample code below to fetch tweets based on tweet_ids. Like other twitter API's, this API is also rate limited, in a single call you can fetch status only for 100 ids. Check the documentation for more details. Also use latest version of twitter4j lib.
ConfigurationBuilder config = new ConfigurationBuilder();
config.setOAuthConsumerKey("consumerKey");
config.setOAuthConsumerSecret("consumerSecret");
config.setOAuthAccessToken("accessToken");
config.setOAuthAccessTokenSecret("accessSecret");
Twitter twitter = new TwitterFactory(config.build()).getInstance();
long ids[] = new long [3];
ids[0] = 568363361278296064l;
ids[1] = 568378166512726017l;
ids[2] = 570544187394772992l;
ResponseList<Status> statuses = twitter.lookup(ids);
for (Status status : statuses) {
System.out.println(status.getText());
}
Upvotes: 3