Saturday, June 29, 2013

How to get facebook oauth_access_token

1- create facebook app

2- use the App ID:  and Site URL: to generate the   oauth_access_token

3-  use the following url to generate oauth_access_token,offline_access

client_id = App ID
redirect_uri = Site URL

4- the return URL will contain the  oauth_access_token

5- Sample code to get friend list using python


import facebook

token = '932750932000980340aa0afaf789a9f9af79a7f97d99a79799a7'

graph = facebook.GraphAPI(token)
#profile = graph.get_object("me")
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")

friend_list = [friend['name'] for friend in friends['data']]

print friend_list


you have to install to make the code work

No comments:

Post a Comment