Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Getting a long-lived access token using the Facebook PHP SDK
$appId = 'aaaaaaaaaaaa';
$appSecret = 'bbbbbbbbbbbb';
// init facebook
$facebook = new Facebook( array( 'appId' => $appId, 'secret' => $appSecret ) );
// get user_id, 0 if not logged in
$user = $facebook->getUser();
// check if user is logged in
if ( $user ) {
// get long-lived access token
$access_token = $facebook->getAccessToken();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment