Reputation: 1243
I just start to learn make an application with using twitter api 1.1. I want to get 3200 tweets of an user but I couldnt find out how can I add pagination ? Please can you show me solition way ? Here is my code. I take only 198 tweets.
import oauth2 as oauth
import json
# Twitter API documentation
# https://dev.twitter.com/docs/api/1.1
# Get access tokens from https://dev.twitter.com/docs/auth/tokens-devtwittercom
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
consumer = oauth.Consumer(key=consumer_key, secret=consumer_secret)
token = oauth.Token(key=access_token, secret=access_secret)
client = oauth.Client(consumer, token)
header, response = client.request('https://api.twitter.com/1.1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=username&count=500')
print len(json.loads(response))
Upvotes: 0
Views: 3743
Reputation: 7513
Twitter's Working with Timelines is a very nice document that explains how it works. At first glance, it would seem that there should be a normal paging scheme and there was early on. However, the amount of traffic that comes in and the fact that the most recent tweets is changing quickly makes this impractical. So, they offered since_id and max_id to ensure you get the latest tweets without duplication.
Upvotes: 1