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?
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:
GetUserTimeline(user_id=None, screen_name=None, since_id=None, max_id=None, count=None, include_rts=True, trim_user=False, exclude_replies=False)
So you want to do GetUserTimeline(screen_name=settings.TWITTER_USER)
Otherwise your string would go as user_id
.