Navigating nodes/connections/objects in Facebook API + Python -
i connecting facebook fine pythonforfacebook, have access token set grants me information, don't know correct syntax getting dictionary friends names , hometown. can me out how should corrected?
import facebook graph = facebook.graphapi("access token") friends = graph.get_connections("me", "friends") print friends[hometown]
ensure have friends_hometown permission need explicitly request field
friends = graph.get_connections("me", "friends", fields="hometown") then cannot access hometowns need understand data structure. friends holds data (which holds friends) , paging parameter.
for fr in friends['data']: if 'hometown' in fr: print fr['id'] + ' ' + fr['hometown']['name']
Comments
Post a Comment