Skip to content Skip to sidebar Skip to footer

Twitter User_timeline Not Returning Enough Tweets

I'm currently using the GET statuses/user_timeline twitter API in python to retrieve tweets, It says in the docs This method can only return up to 3,200 of a user’s most recent T

Solution 1:

You'll have to write code to work with timelines. Twitter's Working with timelines documentation has a discussion of how and why Twitter timelines work the way they do.

Essentially, set your count to the maximum amount (200) and use since_id and max_id to manage reading each page. Alternatively, you can use an existing library to make the task much easier. Here's an example, using the tweepy library.

consumer_key = "<your consumer_key>"
consumer_secret = "<your consumer_secret>"
access_token = "<your access_token>"
access_token_secret = "<your access_token_secret>"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

forstatusin tweepy.Cursor(api.user_timeline, "JoeMayo").items():
    print('status_id: {}, text: {}'.format(status.id, status.text.encode('utf-8')))

Post a Comment for "Twitter User_timeline Not Returning Enough Tweets"