In earlier posts we used facebook php api . Now it’s time to try basic python api usage . Please note that this api is not official .
There are many amazing things you can do with python api , like data mining . So let’s get started.
Get access token from Graph explorer
Install facebook-sdk using pip
pip install facebook-sdk
Get list of all facebook friends
#import this package to print data structure in better way
from pprint import pprint
#use acess token from previous step
graph = facebook.GraphAPI(access_token)
my_profile = graph.get_object("me")
friends = graph.get_connections("me","friends")
#view only first 10 friends
Status update from terminal
graph.put_object("me", "feed", message="python is awesome")
Get likes of friends
#ge likes of first friend
likes = graph.get_connections(friends['data']['id'],"likes")
I’ll add more code soon.