PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 27, 2022

[FIXED] Get page access token with Facebook API 5.0 PHP

 February 27, 2022     facebook, facebook-graph-api, facebook-php-sdk     No comments   

Issue

I need to post messages on a Facebook page. Specifically I want to post via cron.

Here's what the API docs say:

Page Access Token – These access tokens are similar to user access tokens, except that they provide permission to APIs that read, write or modify the data belonging to a Facebook Page. To obtain a page access token you need to start by obtaining a user access token and asking for the manage_pages permission. Once you have the user access token you then get the page access token via the Graph API.

How I can obtain a user access and page access token without a page callback? Is this possible?


Solution

What you need it an Extended Page Token, it is valid forever. You get one like this:

  • Authorize with the manage_pages permission (and publish_pages if you want to post as Page later), to get a User Token
  • Extend the User Token
  • Use /me/accounts?fields=access_token with the Extended User Token to get a list of all your Pages with Extended Page Tokens - or use /page-id?fields=access_token to get an Extended Page Token for a specific Page

Information about all Tokens and how to extend the User Token:

  • https://developers.facebook.com/docs/facebook-login/access-tokens#extending
  • http://www.devils-heaven.com/facebook-access-tokens/


Answered By - andyrandy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing