I have the following code to generate an extended token. No SDK involved. I get the initial temporary token with the Graph API Explorer.
$api_action = 'me/accounts';
$url = 'https://graph.facebook.com/' . $this->facebook_api_version . '/' . $api_action;
$url_with_token = $url . '?access_token=' . $this->facebook_temporary_access_token . '';
$account = json_decode(file_get_contents($url_with_token));
$page_access_token = $account->data[0]->access_token;
// Get extended access token
$access_token = '';
$url = 'https://graph.facebook.com/oauth/access_token?client_id=' . $this->facebook_app_id . '&client_secret=' . $this->facebook_app_secret . '&grant_type=fb_exchange_token&fb_exchange_token=' . $page_access_token;
$result = file_get_contents($url);
$result = str_replace('access_token=', '', $result);
$result = explode('&expires', $result);
$facebook_extended_access_token = $result[0];
echo '<pre>'; print_r($facebook_extended_access_token); echo '</pre>';
return $facebook_extended_access_token;
This application has three pages associated with it. The problem is this only generates an extended token for the Page A. I've verified using the Facebook Toke Debugger.
https://developers.facebook.com/tools/debug/access_token?q=
How can I generate an extended token for Facebook Page B and C and not just A.