0% found this document useful (0 votes)
128 views

How To Use Facebook Graph API - Tleduc

The document provides a 15 step process for obtaining an access token to use the Facebook Graph API to publish posts to a test Facebook page associated with a developer's app. It involves creating an app page and business manager in Facebook, generating a test user access token with appropriate permissions, debugging the token, and using the Graph API Explorer to ultimately retrieve a page access token that can be used to programmatically publish posts to the test page.

Uploaded by

Samit Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views

How To Use Facebook Graph API - Tleduc

The document provides a 15 step process for obtaining an access token to use the Facebook Graph API to publish posts to a test Facebook page associated with a developer's app. It involves creating an app page and business manager in Facebook, generating a test user access token with appropriate permissions, debugging the token, and using the Graph API Explorer to ultimately retrieve a page access token that can be used to programmatically publish posts to the test page.

Uploaded by

Samit Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

how to Use Facebook Graph API -

Access Token
by Tleduc

—> Step 1 : Go the Settings of the Facebook App :

—> 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 4 : Go to ‘Roles —> Test Users’ :


—> Step 5 : Add a new ‘Test Users’ :
- Enable ‘Authorize Test Users for this App’
- Select ‘v3.0’ (it could automatically change to 3.1 : it doesn’t matters)
- Add ‘Login Permissions’ : ‘manage_pages’, ‘publish_pages’,
‘business_management’ and ‘publish_to_groups’
—> Step 6 : Check the ‘permissions this test user granted’ : you need to have at
least the permissions written previously
—> Step 7 : Get the ‘access token for this test user’, select ‘v3.0’ and copy the
access token given

—> 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 10 : Go to ’Get Token’ and ‘Get User Access Token’

—> Step 11 : Select the options


- Select ‘v3.0’
- Select the permissions as followed
- Submit with ‘Get Access Token’

—> Step 12 : Authorize the app to your page, app, etc..


—> Step 13 : Select the ‘Page Access Tokens’ —> Name of your Test Page :
‘Page_App’

—> 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

Use this simple example :

—————————————————————————————————————
—————

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')

—————————————————————————————————————
—————

You might also like