Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 164

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 167

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 170

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 173

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 176

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 178

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 180

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 202

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 206

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 224

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 225

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 227

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 56

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 56

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 56

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 49
How To: Get A Facebook Application Access Token | MasteringAPI

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?