php - Get the 20 most recent photos from an album (JSON) -
i'm trying 20 recent photos album using following json feed: (link)
my code works, issue aren't recent photos album:
<?php $pic_url = "https://graph.facebook.com/10151316456544622/photos?fields=picture,name,source,created_time&limit=20"; //change limit allow more items $pictures = json_decode(file_get_contents($pic_url)); $countpic= sizeof ($pictures->data); // number of pics 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; ?>
instead of getting result graph api may consider use fql more apt situation 1 having. can query photos
fql (documentation) within album
similar graph api , can order same in decreasing created
time, recent one. query like
select src,created,caption photo album_object_id=10151316456544622 order created desc limit 20
which can view through link.
additionally, access facebook's resources through access token, ward of errors @ later stage. may use app access token, looks publicly available data.
Comments
Post a Comment