Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Getting a long-lived access token using the Facebook PHP SDK
<?php
$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
$facebook->setExtendedAccessToken();
$access_token = $facebook->getAccessToken();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.