我目前正试图通过Facebook Graph API在已发布的帖子中获取总照片数。我试过了
我/相册?字段=计数,名称
但这是在计算相册中的照片数量。提前致谢
答案 0 :(得分:0)
$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;