GorillaInR
GorillaInR

Reputation: 675

tweepy api.me() not returning user objects of friends

So from the tweepy documentation, I should be able to user api.me() to get a list of friends a user is following: http://pythonhosted.org/tweepy/html/api.html#user-methods First,I did usual OAuth dance:

import tweepy
consumer_token='#####'
consumer_secret='$$$$$'
access_token='&&&&&'
access_token_secret='****'
auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)
daysinn_friends=api.me('DaysInnCanada')

And then python gave me an error saying:

Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
daysinn_friend=api.me('DaysInnCanada')
TypeError: me() takes exactly 1 argument (2 given)

But I didn't pass 2 arguments into me(), the only argument was the screen_name. I'm really confused and couldn't figure it out. Thanks

Upvotes: 1

Views: 1935

Answers (2)

koogee
koogee

Reputation: 963

The OP wants to get a list of his friends (i.e. people he is following), not people who follow him.

friends = api.friends_ids('DaysInnCanada')
obj = api.lookup_users(user_ids=friends)
for name in obj:
    print name.screen_name

For a list of all attributes associated with a <tweepy.Models.User object>, use name.__getstate__()

Upvotes: 0

rmunn
rmunn

Reputation: 36668

The "extra" parameter that's confusing you is the Python self parameter. I've already written a long explanation of self in https://stackoverflow.com/a/16259484/2314532, so instead of repeating it I'll just point you to that answer. If after reading that you still don't understand what's going on, let me know and I'll see if I can explain further.

Also, looking at the API documentation for tweepy, me() is supposed to take no parameters, and you're passing it one. From glancing at your code, I suspect what you really meant to do is call api.followers("DaysInnCanada"). Or maybe api.get_user("DaysInnCanada"), but I suspect you meant to use followers.

Upvotes: 2

Related Questions