1

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!

  • What do you mean by twitter id? – Jonathan Feb 27 '15 at 16:52
  • I mean the post id which is also referred to as since id in Status object of twitter4j. – user2090166 Mar 2 '15 at 5:01
3

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());
}
  • Thanks, it answers my question! – user2090166 Mar 6 '15 at 12:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.