-
Notifications
You must be signed in to change notification settings - Fork 0
/
fbc.py
24 lines (18 loc) · 843 Bytes
/
fbc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
__author__ = 'Shane_Kao'
import requests
import facebook
def get_short_lived_token(app_id, app_key):
payload = {'grant_type': 'client_credentials', 'client_id': app_id, 'client_secret': app_key}
file = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload)
result = file.text.split("=")[1]
return result
token = get_short_lived_token('XXXXXXXXX', 'XXXXXXXXXX')
def get_facebook_data(object_id, p_fields):
args = p_fields
graph = facebook.GraphAPI(access_token = token, version = '2.7')
profile = graph.get_object(object_id, **args)
return profile
result = get_facebook_data(u'asusclub.tw',
{'fields':'posts.limit(10){created_time,from,message,permalink_url}'})
print repr(result).decode('unicode-escape')