I am using this to retrieve user photos however it always print_r‘s a blank array:
$facebook = new Facebook(array(
'appId' => 'XXX',
'secret' => 'XXX',
'cookie' => true,
));
if ($facebook->getSession()) {
try {
$profile = $facebook->api('/me/photos');
echo "<pre>";
print_r($profile);
} catch (FacebookApiException $e) {
echo $e->getMessage();
exit();
}
}
else {
$login_url = $facebook->getLoginUrl(array(
'next' => 'XXX',
'cancel_url' => 'XXX',
'req_perms' => 'user_about_me,user_location,user_hometown,user_birthday,user_interests,user_likes,user_photos'
));
echo '<a href="'.$login_url.'">Click here to login</a>';
}
If I use:
$profile = $facebook->api('/me');
It print_r‘s an array full of data but not the photo information I am looking for.
Any ideas?
When you get the facebook session you also receive an access token. You have to use it to make valid api requests. Everything that’s not public info require that token. Example of usage:
If doing this you still get empty data, maybe that user does not have any photos.
Good luck!