简体   繁体   中英

Not getting more than 100 photos from facebook albums in php

I am using Facebbok Graph Api to show to photos of facebook albums on my website. The issue is it is showing only 100 photos but my album is having more than 100 photos. I have tried something like this:

$album_image = $fb->get('/'.$album['id'].'/photos?fields=id,source,url&limit=500');   

$album_image = $fb->get('/'.$album['id'].'/photos?fields=id,source,url&limit=500');   

$album_images = $album_image->getDecodedBody();
<?php

require_once __DIR__ . '/Facebook/autoload.php';

$fb = new Facebook\Facebook([
  'app_id' => 'your app id',
  'app_secret' => 'your app secret',
  'default_graph_version' => 'v2.8',
]);

// Sets the default fallback access token so we don't have to pass it to each request
$fb->setDefaultAccessToken('app access token');

try {
  $response = $fb->get('/'your album id'/albums?fields=id,name,picture');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

$album = $response->getDecodedBody();
$album_ids = array();
$album_info = array();
$album_images_id = array();

foreach ($album['data'] as $key => $value) {
  $album_ids[] = $value['id'];
  $album_info[$value['id']] = $value;

  $album_image = $fb->get('/'.$value['id'].'/photos?tab=album&fields=id,source,picture');
  $album_images = $album_image->getDecodedBody();
  $feedEdge = $album_image->getGraphEdge();

    // Page 2 (next 5 results)
    $nextFeed = $fb->next($feedEdge);

    foreach ($nextFeed as $status) {
      var_dump($status->asArray());
    }
}

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM