我正在尝试使用以下 JSON 提要从相册中获取 20 张最近的照片:(链接)
我的代码目前有效,唯一的问题是它们不是相册中的最新照片:
<?php
$pic_url = "https://graph.facebook.com/10151316456544622/photos?fields=picture,name,source,created_time&limit=20"; //change limit to allow more items
$pictures = json_decode(file_get_contents($pic_url));
$countpic= sizeof ($pictures->data); // get the number of pics for later use
for($p=0; $p<$countpic; $p++):
$thumb_url = "https://graph.facebook.com/".$pictures->data[$p]->id."/picture";
$thumb = $pictures->data[$p]->source;
?>
<li>
<a href="<?php echo $thumb_url; ?>" class="fresco hover" data-fresco-group="facebook" data-fresco-caption="<?php echo $pictures->data[$p]->name; ?>">
<div><div class="hover"></div><img style="width: 225px; height:250px;" title="<?php echo $pictures->data[$p]->name; ?>" alt="<?php echo $pictures->data[$p]->name; ?>" src="<?php echo $thumb_url; ?>"></div>
</a>
</li>
<?php endfor; ?>