I’m trying to use python-twitter
. I’m following this tutorial.
Here is my code:
tweet = cache.get('tweet')
if not tweet:
tweet = twitter.Api().GetUserTimeline(settings.TWITTER_USER)[0]
tweet.date = datetime.strptime(tweet.created_at, "%a %b %d %H:%M:%S +0000 %Y")
cache.set('tweet', tweet, settings.TWITTER_TIMEOUT)
But I’m getting next error:
Twitter.error.TwitterError: {'message': '"user_id" must be type int'}
I’ve set the variables like in the tutorial:
TWITTER_USER = 'CaseyNeistat'
TWITTER_TIMEOUT = 3600
Is there anything I’m doing wrong?
2
Answers
The article got created about 9 years ago. So the API could changed many times since then.
Here is the signature of the function from python-twitter documentation:
So you want to do
GetUserTimeline(screen_name=settings.TWITTER_USER)
Otherwise your string would go as
user_id
.Just use
screen_name
as function argument.For example,
GetUserTimeline(screen_name="elonmusk")