I want to get facebook friends using php SDK. I cannot use Latest PHP SDK as it is using namespaces and my application doesn't support namespaces. I get following permissions from user
email,user_birthday,user_status,publish_stream,offline_access,user_friends
And when the code is executed, it shows the following Facebook OATH Dialogue
And you can see in the image that it doens't show user friends permission.
And when I want to get user's friends using PHP SDK using following code:
require_once(APPLICATION_PATH_LIB . "/Facebook/facebook.php");
$facebook = new Facebook(array('appId' => $appId, 'secret' => $appSecret));
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $appId .
"&client_secret=" . $appSecret .
"&grant_type=client_credentials";
$app_token = file_get_contents($token_url);
$app_token = explode("=", $app_token);
$app_token = $app_token[1];
$user = $facebook->getUser();
if ($user) {
$user_profile = $facebook->api('/me', array('access_token' => $app_token));
//echo '<pre>';var_dump($user_profile);die;
$friends = $facebook->api('/me/friends', array('access_token' => $app_token));
echo '<pre>';print_r($friends);
}
And it is giving me following error
OAuthException: An active access token must be used to query information about the current user.