I'm trying to first get the list of friends from a user who is logged in using a facebook account. I have followed this post with no luck: How to retrieve Facebook friend's information with Python-Social-auth and Django
I get and empty friends set everytime I call the view that is supposed to retrieve the facebook friends. Ideally, I would like to retrieve the facebook friends and have an invite button on the side that invites the user's friends to sign up for web app.
This is what I have in my views.py:
social_user = request.user.social_auth.filter(provider='facebook',).first()
if social_user:
url = u'https://graph.facebook.com/{0}/' \
u'friends?fields=id,name,location,picture' \
u'&access_token={1}'.format(
social_user.uid,
social_user.extra_data['access_token'],
)
request2 = urllib2.Request(url)
friends = json.loads(urllib2.urlopen(request2).read()).get('data')
return render_to_response('friends/friends.html', {'user': request.user, 'friends':friends})