
$app_id ='App ID here';
$app_secret ='App Secret here';
$app_url ='App URL here';
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$scope = 'email,offline_access,publish_stream,user_photos,create_event';
//make sure you leave no space after comma between permissions
$scope_params = explode(',',$scope);
$permissions = $facebook->api("/me/permissions");
if(is_array($permissions)){
$premissions_required = '';
foreach($scope_params as $k){
if(!array_key_exists($k, $permissions['data'][0]) )
$premissions_required .= $k.',';
}
if( $premissions_required ) {
$premissions_required = substr($premissions_required, 0, -1);
$oauth_url = 'https://graph.facebook.com/oauth/authorize?client_id=' . $app_id . '&redirect_uri=' .$app_url . '&type=user_agent&display=page&scope=' . $premissions_required;
echo '';
}
}
Hope that helps.
Cheers!




Hmmm, not sure if anyone else has experienced this:
Uncaught OAuthException: An active access token must be used to query information about the current user.
Thanks for your input.
I’m now certain that this errors appears mostly when the app has not responded reasonably. I recently fixed an app with this error and it was resolved instantly when i created indexes on certain columns in DB tables. It really made this error disappear.