Question

I am using TwitterOAuth to get the tweet count of a hashtag but there is one issue; It only returns maximum of 100 results.

I want to get all tweets of a hashtag. Is this possible? Is so, how?

Was it helpful?

Solution 2

I assume you are using get parameter on this url as you haven't shared code.

https://api.twitter.com/1.1/search/tweets.json?q=??&count=??

So you need to specify count here which is described in following twitter api docs.

https://dev.twitter.com/docs/api/1.1/get/search/tweets

Yes there is 100 count limitation. So in that case page parameter can be added but twitter has written why timeline option is better.

https://dev.twitter.com/docs/working-with-timelines

So answering your question you will using query something like this. This will give 2nd page with 100 results. Read the link above to use options like max_id and since_id.

https://api.twitter.com/1.1/search/tweets.json?q=google&count=100&since_id=100

This way extend your 100 results limit and you can always test your query on

https://dev.twitter.com/console

OTHER TIPS

You will need to use the API's cursor feature. This allows you to return pages of information:

https://dev.twitter.com/docs/misc/cursoring

Note that twitter will only let you search for about 2 days of tweets (or less). After that time the search won't return those tweets at all. The tweets still exist on twitter of course, but they are only available on the users page etc.

Are you trying to get all counts of an old hashtag, or a new one? If you are looking for a new hashtag, you should probably run your query multiple times an hour and then filter results and build a list on your server to get a real count.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top