In [ ]:
!pip install -U requests

In [ ]:
!pip install -U facebook-sdk

In [ ]:
token = raw_input()

In [ ]:
import facebook

In [ ]:
graph = facebook.GraphAPI(token, version="2.5")

In [ ]:
graph

In [ ]:
obj = graph.get_object('me')

In [ ]:
print obj

In [ ]:
print obj['name']

In [ ]:
obj = graph.get_object('10201382289514027', fields=['id','name','gender', 'favorite_teams'])
print obj

In [ ]:
obj['favorite_teams']

In [ ]:
obj['favorite_teams'][0]

In [ ]:
print obj['favorite_teams'][0]['name']

In [ ]:
graph.get_object('1590154637906351')

In [ ]:
metadata = graph.get_object('me', metadata=1)

#print metadata  # 有一大堆資料

In [ ]:
# 先看一下有哪些 key
print metadata.keys()

In [ ]:
for x in metadata['metadata']['fields']:
    print x['name']

In [ ]:
for x in metadata['metadata']['connections']:
    print x

In [ ]:
friends = graph.get_connections('me', connection_name = 'friends')
friends

In [ ]:
import requests

In [ ]:
from pprint import pprint

In [ ]:
friends = graph.get_connections('me', connection_name = 'friends')
i = 0
while True:
    pprint(friends)
    for f in friends['data']:
        print i, f
        i+=1
    if 'paging' in friends and 'next' in friends['paging']:
        friends=requests.get(friends['paging']['next']).json()
    else:
        break

In [ ]:
friends