I am trying to follow a python networkx tutorial but its using the python-twitter library and that library deals badly with twitter rate limit compared to tweepy. I want to know how i can do the same thing in tweepy; specifically how do i get the getfriends API in tweepy? Here is the code using python-twitter:
from pylab import *
from networkx import *
import twitter
api = twitter.Api(consumer_key='consumer_key',
consumer_secret='consumer_secret',
access_token_key='access_token',
access_token_secret='access_token_secret')
friends = api.GetFriends()
G = XGraph()
for friend in friends:
G.add_edge('myname',friend.name)
for friend in friends[-3:]:
for user in api.GetFriends(friend.id):
G.add_edge(friend.name,user.name)
I have tried something like this using tweepy:
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth,wait_on_rate_limit=True)
Followers=[]
c=tweepy.Cursor(api.followers).items(100)
for user in c:
print user.screen_name
Followers.append(user.screen_name)
but now i dont know how to continue translating to tweepy to get friends of friends, specifically this part in python-twitter :
for friend in friends[-3:]:
for user in api.GetFriends(friend.id):
G.add_edge(friend.name,user.name)
Please help.