Why does the facebook photo album return an empty array?

1

I'm using the Facebook SDK with Laravel 4. I need to return the images of some of the user who logs in via Facebook.

When I use the user, who is the admin of the APP on Facebook, the images and the albums are returned normally.

However, when I try to do this with any user, other than an administrator, an empty array is returned.

The code I'm using is as follows:

$session = new FacebookSession(Session::get('facebook.token'));

$request = new FacebookRequest(
    $session,
    'GET',
    '/me/albums',
    ['fields' => 'name,photos.limit(20){source},id']
);

$response = $request->execute()->getGraphObject();

$imagesOfAllAlbums = [];

foreach ($response->asArray() as $albuns) {

   foreach ($albuns as $k => $album) {

    if (empty($album->photos)) continue;

    foreach ($album->photos as $images) {

        foreach ($images as $image) {

            if (empty($image->source)) continue;

            $imagesOfAllAlbums[$album->name][] = $image->source;
        }
        }
   }
}

count($imagesOfAllAlbums); // 0

In the first case, this would return this:

[
   'Nome do Album' => [
         'imagem_1.jpg',
         'imagem_2.jpg',
    ]
]
    
asked by anonymous 23.07.2015 / 22:26

0 answers