My head is currently going nuts trying to figure out the most effective way to retrieve the albums from a fan page I own, to an online page. I’ve seen a code that used FQL and it worked, but it’s too slow and apparently it’s outdated.
I’ve browsed around and came across the Graph API concept but it looks a bit hard to understand. By the way I already have an app registered and I also started to search around the Graph Explorer but I can’t come to a conclusion.
Are there any tutorials out there?
EDIT: I’ve tried this code:
<?php
$album_id = 'myalbumid';
$access_token = 'accesstoken';
$url = "https://graph.facebook.com/{$album_id}/photos?access_token={$access_token}";
$image = json_decode(file_get_contents($url));
foreach($image->data as $img){
echo "<img src='{$img->images[6]->source}' /> ";
}
?>
And it works, it displays all the photos from a given album. But what if I want it to display all albums (including thumbs) and the user navigates through them?
Requesting the following will give you a reply with all albums and photos in those albums:
You’ll want to replace
CocaCola
in the example with your own page name or ID.This is called nested requests or field expansion. There are several detailed examples on the Facebook Documentation site.
A few comments for you to help you along the way:
file_get_contents()
is okay for sandbox testing, but you should use the Facebook PHP SDK for production code.