Ravindra S
Ravindra S

Reputation: 6432

Twitter4j API: setMaxId() not working properly

I am using twitter4j to download old tweets using max_id as following:

TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
String emotion = "#sad OR #happy OR #angry OR #anxious OR #fear OR #surprised";	
Query query = new Query(emotion);
query.setMaxId(576017086843088896L);	// start downloading tweets older than this tweet
query.setCount(100);
QueryResult queryResult = twitter.search(query); // returns zero tweets

I have tried setting up various MaxIds from previously downloaded valid status ids. But it is returning zero tweets. If I don't set MaxId, it is working fine and returning recent tweets. Any idea what's going wrong?

Update: I have tried using following configuration as well (removed maxId configuration). This also resulted in zero number of tweets.

query.since("2015-01-01");
query.until("2015-03-11");

Upvotes: 0

Views: 361

Answers (1)

Ramanan
Ramanan

Reputation: 1000

twitter.search(query)

This will fetch tweets for the past 7 days only.

You cannot search before that time. You may have to look at private API's like https://gnip.com/sources/twitter/historical/

Upvotes: 1

Related Questions