Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get more than 100 tweets?

Tags:

java

twitter4j

Is it possible to get more than 100 tweets using the Twitter4j API?
If so can anyone point out the way to do so??

like image 312
Nithish Inpursuit Ofhappiness Avatar asked Jul 26 '13 18:07

Nithish Inpursuit Ofhappiness


People also ask

What is the maximum number of tweets per page in Twitter?

The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the "rpp" parameter in the old Search API. Thanks for contributing an answer to Stack Overflow!

How do I set Twitter rate limits?

So what you do is run your first 100, then look for the lowest ID and run another query, this time setting that ID (less 1) as your maximum ID. This will return the next 100, which you append to the previous results. You can then run this loop as many times as you need subject to Twitter rate limits.

How do I get the most recent tweets in Twitter?

If you want to get the most recent tweets, you should use t.setMaxId () or t.setSinceId () set to lower or higher than your current lowest/highest ID respectively. Show activity on this post. The number of tweets to return per page, up to a maximum of 100.

How many tweets can be returned from a single page?

The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the "rpp" parameter in the old Search API. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! But avoid … Asking for help, clarification, or responding to other answers.


2 Answers

Would need to see your code to provide a code example specific to your case, but you can do this through since_id or max_id.

This information is for the Twitter API.

To get the previous 100 tweets:

  1. find the the lowest id in the set that you just retrieved with your query
  2. perform the same query with the max_id option set to the id you just found.

To get the next 100 tweets:

  1. find the the highest id in the set that you just retrieved with your query
  2. perform the same query with the since_id option set to the id you just found.

In Twitter4j, your Query object has two fields that represent the above API options: sinceId and maxId.

like image 88
Luke Willis Avatar answered Sep 30 '22 19:09

Luke Willis


You can't load more than 100 tweet per request but i don't know why you want this, instead you can load all tweets in "Endless page" i.e loading 10 items each time the user scroll a list .

for example

Query query = new Query("stackoverflow");
query.setCount(10);// sets the number of tweets to return per page, up to a max of 100
QueryResult  result = twitter.search(query);

now if you want to load the next page simple easy

if(result.hasNext())//there is more pages to load
{
query = result.nextQuery();
result = twitter.search(query);
}

and so on.

like image 37
confucius Avatar answered Sep 30 '22 18:09

confucius