Tweepy user id from mention
python, tweepy, twitter
Solution
Here's what works for me with the most recent `tweepy` version:
import tweepy
auth = tweepy.OAuthHandler(<consumer_key>, <consumer_secret>)
auth.set_access_token(<key>, <secret>)
api = tweepy.API(auth)
mentions = api.mentions_timeline(count=1)
for mention in mentions:
print mention.text
print mention.user.screen_name
Hope that helps.
Problem
I am using `tweepy` to set up a script that finds the latest mention of my username. From this, I want to retrieve the text of the tweet, and their twitter user name. However, I don't seem to be able to retrieve the actual @ username, only their id number. Any suggestions? Below is my code. The question marks are where I need the proper syntax: ``` myMentions = tweepy.Cursor (api.mentions).items(1) for mention in myMentions: statusText = mention.text statusUser = mention.???? ``` Thanks so much!