skip to Main Content

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 ?

3

Answers


  1. 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

    Login or Signup to reply.
  2. import tweepy

    api = tweepy.API(auth)

    api.mentions_timeline()

    Login or Signup to reply.
  3. Try going to your profile using the same of which you’re using the API and see whether the mentions exists in your profile.
    and try mentioning the twitter account from different account which you trying from.
    This might be the case where twitter had limited your activities and replies/tweets are not visible of that account.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search