How To Use Facebook Graph API - Tleduc
How To Use Facebook Graph API - Tleduc
Access Token
by Tleduc
—> Step 2 : Create a “App Page”, choose a “Business Page” (left choice) and
following Facebook’s instruction to the page be recognise as part of the App : “the
name of the page should contain the name of the app, and the page must be in the
App Page category”
—> Step 3 : Create a Business Manager assign with the app : follow Facebook
instructions
—> Step 8 :
- Go the Access Token Debuger : https://developers.facebook.com/tools/debug/
accesstoken/?
- Put you access token
- Select ‘v3.0’ as the ‘API Version’
- Check the scopes (permission granted), you need to find at the least the
previous ones
- The Expire time of the token is short : click on ‘Extend Access Token’ , write
your password and copy the access token given
—> Step 9 : Go to the Graph Explorer : https://developers.facebook.com/tools/
explorer/
—> Step 14 : Activate the premission to publish on the page : select ‘Request
publish_pages’
—> Step 15 : You now have the access token to publish posts on your Test
Page : Go your script to add the token access
—————————————————————————————————————
—————
import facebook
print('Facebook Version :',facebook.__version__)
print('App Version : 3.0')
test_user_access_token = ""
graph = facebook.GraphAPI(access_token=test_user_access_token)
page_id_test = ""
message = """
"""
# Need :
# - Parent_object : page id
# - connection_name : the wall of the page
# - message : the message you want to send
graph.put_object(parent_object=page_id_test, connection_name="feed",
message=message)
# No need to put the page id, the access token has it inside ?
# graph.put_photo(image=open('img.png', 'rb'), message=message)
print('POST SENT')
—————————————————————————————————————
—————