facebookwebembedphotofacebook-page

How can I let my users embed all their albums from fan page facebook to my website


I want that owner of the fanpage can fill in a form on my website. (Their info will be stored in a MySQL database). Then when navigated to their picture page their foto albums are displayed. I don't want them to add album by album but I want it so that when they post a new album they don't have to add them.

I've book looking through the graph api, developpers fb and so on but I cant find anything on how to make it this way.

Thanks to Zach L I came so far:

$urlfanpage = "http://graph.facebook.com/FANPAGE/albums?fields=id,name&limit=0";
$objfanpage = json_decode(file_get_contents($urlfanpage));
                                                        
foreach($objfanpage->data as $itemfanpage) {                                                                    
$ifanpage = array();
foreach($itemfanpage as $keyalbum => $valalbum){
$ifanpage[$keyalbum] = $valalbum;
                }
$idalbum = $ifanpage['id'];
print_r($ifanpage['name']);  ?> <br><br>
                                
<script type='text/javascript'>     
                                
$.getJSON('http://graph.facebook.com/<?php print_r($idalbum); ?>/photos')     
.then(function(response) {

// 0-8, 0 returns the largest available images, 8 the smallest
var imageIndex = 4;

var images = _(response.data)
    .chain()
    .pluck('images')
    .pluck(imageIndex)
    .value();

console.log(images);

_(images).each(function(image) {
    $('#image-container').append(
        $('<img>').attr('src', image.source)
    );
});

});

</script>   


<div id="image-container"></div>  <br><br><br><br><br><br><br><br> 

 <?php 
$ifanpage++;
}

This posts all pictures from the FanPage. What I want is to make albums then when clicked on prompt a lightbox with the pictures from that album.


Solution

  • You were right to look through the developers.facebook.com and the graph api stuff. Thats where your answers ultimately lie.

    Its not immediately clear what you're exactly trying to do, but things are different depending on where the albums are stored. If you're talking about adding albums from a facebook "fan page" or other public "non-profile" page, then you don't have to worry about authentication, and can do everything using json returned from api calls like http://graph.facebook.com/{pageID}/albums.

    Maybe you can get some inspiration from my jQuery plugin FBalbum, though you should probably have the majority of your code server side...

    If you're trying to get the ability to load personal albums on the page, you're going to have to worry about all kinds of authentication stuff, and possibly have to have code to actually grab these photos after authentication, and then make a copy to your host. (I'm not 100% sure I'm right on these points)