facebook-sdk 的套件

reference from :
http://jialin128.pixnet.net/blog/post/151421243-%5Bpython%5D-facebook-api-in-python-%E5%8F%96%E5%BE%97%E7%99%BC%E4%BD%88%E6%96%87%E7%AB%A0%E8%88%87%E5%80%8B%E4%BA%BA

import facebook

token = ‘ ’ #貼上token
graph = facebook.GraphAPI(access_token = token)
me_info = graph.get_object(‘me’)
print (me_info) #以字典的資料型態印出,裡面有timezone, last_name, id, gender, name……等key
print (‘我的Facebook名字是:’, me_info[‘name’]) #key為name,取出該key之value

posts = graph.get_connections(id = ‘me’, connection_name = ‘posts’)
print (“共有”, len(posts), “篇PO文”)

for each in posts[‘data’]:
 #if ‘message’ in each and ‘likes’ in each: #有po文與按讚
 if ‘message’ in each:
 print (‘時間:’, each[‘created_time’])
 print (‘內容:’, each[‘message’])
 #likes = each[‘likes’][‘data’] #取得按讚的人的資料
 #print(‘共有’, len(likes), “個讚,按讚的人:”)
 #for each_like in likes:
 # print (‘Id:’, each_like[‘id’],’Name:’, each_like[‘name’])
 print (‘ — — — — — — — — — — — — — — — — — — — — — ‘)

顯示不是很正確,應該是Lib舊

token = ‘EAACEdEose0cBACYMHBwmZBv6lg88SS0UTOQbwwcmbsUHUhEExMr1k5cAVZBCEdyqjy8OrQxmIcJpkZAM0YSzSoMedB5fYHV6v9aHBk8vcc0XbP7MYwRilfjhdrULefegckMeyIwHqoNZBNNVEetveZBmpPO6ClwMdmnCROdlvPhOJiuEsSDhSpZC5bkUJKvsaPe16ExkKr4D5aKiRea1b82sBJ4VAKTRgZD’ #貼上token
graph = facebook.GraphAPI(access_token = token)
me_info = graph.get_object(‘me’)
print (me_info) #以字典的資料型態印出,裡面有timezone, last_name, id, gender, name……等key
print (‘我的Facebook名字是:’, me_info[‘name’]) #key為name,取出該key之value

posts = graph.get_connections(id = ‘me’, connection_name = ‘posts’)
print (“共有”, len(posts), “篇PO文”)

print(posts)

for each in posts[‘data’]:
 #if ‘message’ in each and ‘likes’ in each: #有po文與按讚
 if ‘message’ in each:
 print (‘時間:’, each[‘created_time’])
 print (‘內容:’, each[‘message’])
 #likes = each[‘likes’][‘data’] #取得按讚的人的資料
 #print(‘共有’, len(likes), “個讚,按讚的人:”)
 #for each_like in likes:
 # print (‘Id:’, each_like[‘id’],’Name:’, each_like[‘name’])
 print (‘ — — — — — — — — — — — — — — — — — — — — — ‘)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.