GLHF GLHF - 6 months ago 61
Python Question

Tweepy mentions_timeline returns an empty list

I just started to make a Twitter Api. Normally I don't have a Twitter account, for this api I created one. I Tweeted 4 times, including some mentions. But when I use

mentions_timeline
like this;

my_mentions = api.mentions_timeline()
#print(my_mentions)
#output: []


After then I do a for loop on my_mentions with parameters
text
,
screen_name
but nothing returned.

What I'm doing wrong here? Why it's an empty list since I mentioned some people in the tweets + how can I search mentions for another user? Is there a parameter in
mentions_timeline()
object like
screen_name
or
id
?

Answer

Try using the new Cursor Object as follows:

api = tweepy.API(auth)

for mentions in tweepy.Cursor(api.mentions_timeline).items():
    # process mentions here
    print mentions.text

as per Twitters documentation here

Returns the 20 most recent mentions (tweets containing a users’s @screen_name) for the authenticating user.

so you cannot check other users mentions using this method. To achieve this, you will have to uses twitters search api. for tweepy's documentation check here