Last active
May 22, 2016 13:18
-
-
Save nonZero/bab3480fc6f80a1a46d3a3a3179e140b to your computer and use it in GitHub Desktop.
get access token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import secrets | |
URL = "https://graph.facebook.com/oauth/access_token" | |
r = requests.get(URL, { | |
'client_id': secrets.APP_ID, | |
'client_secret': secrets.APP_SECRET, | |
'grant_type': 'client_credentials', | |
}) | |
r.raise_for_status() | |
# print(r.text) | |
key, value = r.text.split("=") | |
assert key == "access_token" | |
with open("TOKEN.txt", "w") as f: | |
f.write(value) | |
print("OK") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
import facebook | |
with open("TOKEN.txt") as f: | |
TOKEN = f.read().strip() | |
graph = facebook.GraphAPI(access_token=TOKEN, version='2.5') | |
# o = graph.get_object("DonaldTrump", | |
# fields="about,website,name,posts{type,message}") | |
o = graph.get_object("DonaldTrump/posts") | |
pprint(o) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment