Facebook API Python

Asked

Viewed 1,219 times

0

Personal is it possible to list ALL groups of a friend on the face? Like show the groups he is in?

I found this code but it’s not what I want, it just shows friends:

import urllib2
import json
url = 'https://graph.facebook.com/me/friends?access_token=TOKEN'
resp = urllib2.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
for amigo in data['data']:
   print (amigo['name'])

1 answer

0


Have you tried replacing Friends with groups in the url? Remember that to access this information, the user must authorize access. In configuring your app, you must access the permissions and register that you are requesting user groups:

More information: https://developers.facebook.com/docs/graph-api/reference/user/groups/

To work with facebook, you can also use facepy:

pip install facepy

It’s much simpler to get user information:

from facepy import GraphAPI

graph = GraphAPI('token_usuario')
data = graph.get('me?fields=id,email,name')
#data {u'id': u'11111111', u'name': u'Puam Dias'}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.