NH3
NH3

Reputation: 189

How to fetch tweets of a given user?

I'm trying to use the Twitter API in order to automatically fetch the last tweet of a given user, but I'm having trouble :/

I am using this library : https://code.google.com/p/python-twitter/

I installed it, everything seems working, but when I try to fetch the timeline of a user, I only get all my timeline :(

Here is my code:

import twitter

api = twitter.Api(consumer_key='***', consumer_secret='****', access_token_key='***', access_token_secret='****')
statuses = api.GetUserTimeline('@twitterapi')
print [s.text for s in statuses]

Is there something I missed ?

Upvotes: 0

Views: 615

Answers (2)

xycmu
xycmu

Reputation: 1

You must explicitly enter screen_name= or user_id= otherwise the value defaults to the authenticated user.

Examples:

statuses = api.GetUserTimeline(screen_name='some_handle')

or

statuses = api.GetUserTimeline(user_id=22233344)

Upvotes: 0

user2117680
user2117680

Reputation: 91

I believe you have to provide the userId rather than the screen_name in order for the GetUserTimeLine to work.

Also, although you might expect that this would return the equivalent of that user's home status page, it does not. Instead, it returns just the tweets from that user.

The twitter API documentation mentions another method - GetFriendsTimeline, but, despite being listed in the documentation, it doesn't seem to exist as far as I can tell.

Upvotes: 1

Related Questions