0
votes

I would like to aggregate/page through the search tweets using the new Search/Tweets v1.1 Twitter API. However, I can't understand how since_id and max_id works to do paging or get more tweets. Didn't get the idea of them.

Can anyone possibly do a simple example with some explanation? preferably in php.

Thanks!

1

1 Answers

0
votes

Every tweet ever created is an incrementing value, each tweet from the API is assigned id_str

This can be used as an offset for future requests

The value expected for max_id is the limit of the offset

So imagine the latest tweet result from the API the id_str is: 345923546427568120

Subtrack your tweets per page e.g 10 from that number and then do your next request with:

since_id=345923546427568100&max_id=345923546427568110 back 10 tweets since_id=345923546427568090&max_id=345923546427568100 back 20 tweets since_id=345923546427568080&max_id=345923546427568090 back 30 tweets

The initial 345923546427568120 value can be set somewhere e.g session or a js var to go forward after going back some tweets, or better yet cache the result set for a short time.

Hope it helps