Some of the features in Facebook Graph API requires a special kind of tokens called “app access token“. Features like Facebook Test Accounts and Facebook Insights make use of this token.

So how to obtain a Facebook Application access_token?
This can be easily achieved using file_get_contents():

$APPLICATION_ID = "APP_ID";
$APPLICATION_SECRET = "APP_SECRET";

$token_url =	"https://graph.facebook.com/oauth/access_token?" .
				"client_id=" . $APPLICATION_ID .
				"&client_secret=" . $APPLICATION_SECRET .
				"&grant_type=client_credentials";
$app_token = file_get_contents($token_url);
Back to top
 
  • Pingback: Introduction To Facebook Test Users Accounts With PHP-SDK | API? Yes Master!

  • Pingback: How To: Handle Application Requests Using The Facebook Graph API | API? Yes Master!

  • yanipan

    seems easy when  you show it like that :)
    thanks

  • sohchai

    even simpler if using graph api

    $access_token = $facebook->getAccessToken();

    • http://www.facebook.com/people/Michael-Panneman/631638897 Michael Panneman

      Not the same token afaik

  • Sjnilanr

    not working

  • titi

    Those whom it’s not working for, check your php.ini to allow fopen of url.

  • Bas Taller

    Looks like currently it works as simple as 
    $APP_TOKEN = $APPLICATION_ID.’|’.$APPLICATION_SECRET;

  • Yondri

    Really helpfull, thanks.

  • Jas

    thank you.

  • http://www.facebook.com/ashely.hills.73 Ashely Hills

    do you have the code for android to perform the same task?

  • Sam Choudhary

    not working screen is blank