A page token allows you to post a message to a page authored by the page itself instead of your own name.
-
To publish a post to a page you send a POST REQUEST to this edge (link) having this fields: "message"=>"the message to be sent to that page"
https://graph.facebook.com/v2.1/PAGE_ID/feed
You need an access_token, using the GraphExplorer you can create an Access Token for testing, go to the graph explorer by navigating to:
https://developers.facebook.com/tools/explorer
If you debug this access token (that one obtained via graph explorer) then you may get notified about this access token has no PROFILE_ID:
App ID 301787956693381 : ascinformatix
User ID 484896668316843 : Christian Salazar
Issued Unknown
Expires 1412967600 (in about an hour)
Valid True
Origin Web
Scopes public_profile, manage_pages, publish_actions
When this situation occurs then when you post the message it will be authored by you, instead of the page. That facebook visitors users may get confused because they think you are sending messages to that page. In the opposite case: you want from your visitors to think that this messages are sent by the page itself
How to obtain a page-access-token
Reference:
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens
-
go to the menu tools/"Graph API Explorer" in:
https://developers.facebook.com/
-
choose the application, that one designed to be used to publish messages to a PAGE.
-
click button "Get Access Token" , then "clear" button, close dialog box by clicking "cancel", then reopen it again and now choose the following "extended permissions", as result you may obtain a short-lived access token.
manage_pages, publish_actions
-
A pop-dialog will shown, asking you grant permissions to that application. Accept.
-
A short-lived access token is created for you WITHOUT THE PROFILE_ID, dont worry. Use that access token to go to the next step
-
Debug the obtained Access Token (click Debug) in order to get your USER_ID.
App ID 787119291327245 : YOUR_APP_NAME
User ID 491662644306912 : Christian Salazar
Issued Unknown
Expires 1412974800 (in about an hour)
Valid True
Origin Web
Scopes public_profile, manage_pages, publish_actions
-
Make a GET query to this UNVERSIONED edge, using the obtained USER_ID:
https://graph.facebook.com/491662644306912/accounts (DONT BROWSE TO IT, INSTEAD, COPY THE "491662644306912/accounts" INTO THE Graph Api Explorer and click SUBMIT)
8. As result you will see:
{
"data": [
{
"category": "Internet/software",
"name": "ASC Informatix C.A.",
"access_token": "CAALL4X3BYw0BACykg4uvWBITJCTyldGiODjQZAFadmAPptYAmZBVuTpbLR61pgLcygss4YBBfWh6SfMfXVDpJDNYKwexOCLtHzEwERN8LiKGwQsFky7ohoWSdyNcWW8quuBmepc39lufgZBT18OSDqarkTZBPJtoqUZByP7ZBT3De9teJQhSfQI3ZAQMDswia2Aq9Ei6NPpmAZDZD",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
],
"id": "479413205454312"
},
- The required "page access_token" is that one in the result under the field labeled: "access_token", try debugging it and now you will see the "Profile ID" field. Future messages sent using this access token using the edge "/v2.1/page_id/feed" will be authored by the ProfileID identity.
App ID 787119291327245 : PropertyWarehousesPageManager
Profile ID 479413205454312
User ID 491662644306912 : Christian Salazar
Issued Unknown
Expires 1412974800 (in about an hour)
Valid True
Origin Web
Scopes public_profile, manage_pages, publish_actions
ALTERNATIVES
https://developers.facebook.com/tools/debug/accesstoken/?q=ACCESS_TOKEN_HERE
and click "extend access token"
DONE.