0
votes

I'm trying to get and generate a Twitter timeline from PHP and Javascript. So I doing the following things.

1- Get an initial tweets for #OneHashtag, with this query params: count=20, since_id=0, max_id=NULL (no max_id param)

2- Set my since_id variable with the newest tweet previosly retrieved.

3- Set max_id variable with SINCE_ID + 20 (count parameter)

4- Make the query with this new params

My problem and question is, this approuch is correct? And second, i'm having problems to perform addition beetween SINCE_ID + 20 in javascript, to set my new params and make the ajax request.

Much appreciate your help! Regards.

1

1 Answers

3
votes

You don't want to add 20 to the ID; these IDs are huge, adding 20 to the ID won't give you what you need, and you will get problems if more than 20 tweets have been posted since your last update.

See Working with Timelines for more information, including the problem with 'pages' (or, adding 20 in your example).

It depends on which way you're going. If you want to load tweets older than your 20, you would set max_id to the ID of the oldest tweet you have. If you want to load tweets newer than your 20, you would set since_id to the ID of the newest tweet you have. Note that, as explained in those docs, when you use max_id, the tweet with that ID will be returned in the results again.