Search code examples
pythonpython-2.7twittertimeline

GetUserTimeline always returns my own timeline


I am using python-twitter library, but I am unable to get the timeline of a specified user. Example

print [s.text for s in api.GetUserTimeline('@BarackObama')]

returns:

[u'test']

which is my last tweet (api is the object returned by tweeter.Api(...)).

Can someone help me with this?

EDIT: The complete code:

import twitter
api = twitter.Api(consumer_key='',consumer_secret='',access_token_key='',access_token_key='')
print [s.text for s in api.GetUserTimeline('BarackObama')]

Solution

  • Try this instead (screen_name will accept @BarackObama, BarackObama or barackobama):

    print [s.text for s in api.GetUserTimeline(screen_name='@BarackObama')]
    

    (c.f. GetUserTimeline test code in twitter_test.py - which is to say that the documentation needs to be updated)