简体   繁体   中英

Get Total Photo Count in a published post via Facebook Graph API

I am currently trying to get the total photo count in a published post via Facebook Graph API. I have tried

me/albums?fields=count,name

but this is counting the number of photos in an album. Thanks in advance

For example, total photo count is four

 $count =0;
 $ALLalbums = $facebook->api('/me/albums?fields=id'); 
 $pics = array();
 foreach ($ALLalbums['data'] as $album) {
 $pics = $facebook->api('/'.$album['id'].'/photos?fields=source,picture');
 $pics[$album['id']] = $pics['data'];
}  
//Albums
foreach ($pics as $album) {
//Count Pics Inside each album
foreach ($album as $img) {
$count++;
// you can get image as well by $img['source'];
}
}
echo $count;

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