Access Facebook Photo Albums using PHP - v1.0

I think it will be great if you can access your Facebook photo albums on your website. I have created an easy way to access your Facebook albums and photos on your site. Like the previous tutorial on 'How to upload photos on Facebook using PHP', this tutorial also requires the appId and secret code of your Facebook application. I will release updates of this post in near future The new version will include the comments posting on the photos.
Lets see it working...

Live Demo Download Script
PHP Code:
 require_once 'library/facebook.php';
  $facebook = new Facebook(array(
    'appId' => $app_id,
    'secret' => $app_secret,
    'cookie' => true
    header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos'))}");
  $me = $facebook->api('/me');
 }catch(Exception $e){
  echo $e->getMessage();
  echo '<p>Please try clearing your browser cookies or <a href="">click here</a>.</p>';
  <script type="text/javascript" src=""></script> 
  <script type="text/javascript" src=""></script> 
  <script type="text/javascript"> 
  $(document).ready(function() {
    fx: 'fade'
  <title> | Access facebook Albums on your site using PHP</title>
 $albums = $facebook->api('/me/albums');

 $action = $_REQUEST['action'];

 $album_id = '';
 if(isset($action) && $action=='viewalbum'){ 
  $album_id = $_REQUEST['album_id'];
  $photos = $facebook->api("/{$album_id}/photos");
  <div class="slideshow"> 
  foreach($photos['data'] as $photo)
   echo "<img src='{$photo['source']}' />";

 $pageURL .= 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 echo '<div class="alb">';
  $and = '&';
  $and = '?';

 echo '<p class="hd">My Albums</p>';
 foreach($albums['data'] as $album)
  if($album_id == $album['id']){
   $name = '<b><u>'.$album['name'].'</u></b>';
   $name = $album['name'];
  echo '<p>'."<a href=".$pageURL.$and."action=viewalbum&album_id=".$album['id'].">".$name.'</a></p>';
 echo '</div>';
CSS Code:
 font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
.alb {
 margin: auto;
.alb p{
 background-color: #EDEFF4;
.alb p.hd{
 background-color: #EDEFF4;
 color: #1C2A47;
 font-size: 16px;
.alb p a{
 color: #3B5998;
 cursor: pointer;
 text-decoration: none;
 font-size: 11px;
 line-height: 25px;
 margin: auto;
.slideshow img {
 padding: 15px;
 border: 1px solid #ccc;
 background-color: #eee;


facebook dosen't redirect back to site

demo link is suspended :-( i don't believe is this activity is legal or not ...

i don't know why the demo link is suspended here is the link: i don't know is this activity is legal or not why they have suspend the domain name... creating confusing .... :-(
This link show
Not Found

The requested URL /fbAlbum/ was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

This comment has been removed by the author.

Hey this link is not working please reply fast its very urgent..

@Feroz, Download link has been updated.

Buddy its not asking for login id & password of Facebook .can share some steps for that . its humble request

@Feroz, Its asking for login. I think you are already logged in your Facebook account. Try on another browser.

Hey dude thanks a lot .its working.I appreciate your help..
just showing 2 warnings as
( ! ) Notice: Undefined index: action in C:\wamp\www\facebookAlbum\photos.php on line 67


( ! ) Notice: Undefined variable: pageURL in C:\wamp\www\facebookAlbum\photos.php on line 85

An active access token must be used to query information about the current user.
Please try clearing your browser cookies or click here.

We would love to hear from you...

back to top