How To Display Facebook Page Photo Albums on Website Using PHP?

display-facebook-photos-on-website-1

In this tutorial, I will show you how to display Facebook page photo albums on website using PHP.

Photo albums from your Facebook page are not shown to your website visitors. You spend a lot of time creating, editing, and managing your photo albums. But your fans, audience, and customers from your website still do not see your Facebook photo albums.

Our code in this tutorial will allow you to automatically display your Facebook page photo albums on your website using PHP. Create and edit your photo albums on Facebook and any changes will also be reflected on your website.

Source Code Overview

Today we’re going to do a code that:

1. Gets photo albums and photos of a Facebook fan page (using Facebook Graph API).

2. Display these photos to a webpage (assuming it is your website) beautifully with Bootstrap. It is also responsive so it’s one advantage for mobile devices. If you’re not yet familiar with this awesome front-end framework, see our step by step Bootstrap tutorial here.

3. Use Bootstrap Image Gallery extension to make an awesome image pop-up presentation. This extension is fully responsive and touch-enabled. Good for every mobile device!

Don’t want to code?

By the way, if you realized you do not want to code and you need more features, you can use a website plugin called SociableKIT.

You can easily customize the look and feel of your Facebook page photo albums and embed them on your website within a few clicks. Following this tutorial: Embed Facebook page photo albums on website. There’s also an option to embed only one photo album on Facebook.

There’s a free plan that you can use if you don’t need the premium features of SociableKIT. But if you like coding, continue with our tutorial below!

Benefits

Use this code to enjoy the following benefits.

  1. You save server disk space because the photos don’t reside in your hosting provider.
  2. You got an instant photo manager which Facebook photos. It becomes awesome and new features are added frequently.
  3. You save bandwidth since the photos shown on your website are loaded from Facebook’s servers.
  4. Please add your comment if you know other advantages.

Get your page access token

Get your page access token before you can get any data from your Facebook page via the graph API, you need a “page” access token.

Follow this detailed tutorial about how to get a page access token: How to get a Facebook page access token?

Replace YOUR_ACCESS_TOKEN with your page access token.

Create index.php with Basic HTML Code

Create index.php and with the following basic HTML code.

<?php
$page_title = "Photo Albums";
?>
<!DOCTYPE html>
<html lang="en">
<head>
 
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
 
    <title><?php echo $page_title; ?></title>
 
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    <style>
    .col-md-4{
        margin: 0 0 2em 0;
    }
    </style>
</head>
<body>
 
<div class="container">
 
</div>
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
 
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
 
</body>
</html>

Build and Decode Photo Albums JSON link

Inside the DIV with a “container” class, put the page title, specify the Facebook page ID and decode the JSON string from a graph API URL.

<?php
echo "<div class='col-lg-12'>";
    echo "<h1 class='page-header'>{$page_title}</h1>";
echo "</div>";
 
$access_token="YOUR_ACCESS_TOKEN";
 
$fields="id,name,description,link,cover_photo,count";
$fb_page_id = "221167777906963";
 
$json_link = "https://graph.facebook.com/v2.8/{$fb_page_id}/albums?fields={$fields}&access_token={$access_token}";
$json = file_get_contents($json_link);
 
$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
 
$album_count = count($obj['data']);
?>

Retrieve Photo Albums

Loop through the retrieved content. Put the following code under $album_count variable on step 2 above. It links to another PHP file called photos.php where the user can view the photos inside the album.

for($x=0; $x<$album_count; $x++){
 
    $id = isset($obj['data'][$x]['id']) ? $obj['data'][$x]['id'] : "";
    $name = isset($obj['data'][$x]['name']) ? $obj['data'][$x]['name'] : "";
    $url_name=urlencode($name);
    $description = isset($obj['data'][$x]['description']) ? $obj['data'][$x]['description'] : "";
    $link = isset($obj['data'][$x]['link']) ? $obj['data'][$x]['link'] : "";
 
    $cover_photo = isset($obj['data'][$x]['cover_photo']['id']) ? $obj['data'][$x]['cover_photo']['id'] : "";
 
    // use this for older access tokens:
    // $cover_photo = isset($obj['data'][$x]['cover_photo']) ? $obj['data'][$x]['cover_photo'] : "";
     
    $count = isset($obj['data'][$x]['count']) ? $obj['data'][$x]['count'] : "";
 
    // if you want to exclude an album, just add the name on the if statement
    if(
        $name!="Profile Pictures" &&
        $name!="Cover Photos" &&
        $name!="Timeline Photos"
    ){
 
        $show_pictures_link = "photos.php?album_id={$id}&album_name={$name}";
 
        echo "<div class='col-md-4'>";
            echo "<a href='{$show_pictures_link}'>";
                echo "<img class='img-responsive' src='https://graph.facebook.com/v2.3/{$cover_photo}/picture?access_token={$access_token}' alt=''>";
            echo "</a>";
            echo "<h3>";
                echo "<a href='{$show_pictures_link}'>{$name}</a>";
            echo "</h3>";
 
            $count_text="Photo";
            if($count>1){ $count_text="Photos"; }
 
            echo "<p>";
                echo "<div style='color:#888;'>{$count} {$count_text} / <a href='{$link}' target='_blank'>View on Facebook</a></div>";
                echo $description;
            echo "</p>";
        echo "</div>";
    }
}

Create photos.php with GET request

Create photos.php with the following PHP code the retrieves value from a GET request. We’ll get the album ID and Name that can be used to the page title.

<?php
$album_id = isset($_GET['album_id']) ? $_GET['album_id'] : die('Album ID not specified.');
$album_name = isset($_GET['album_name']) ? $_GET['album_name'] : die('Album name not specified.');
 
$page_title = "{$album_name} Photos";
?>

Basic HTML Code for photos.php

Under the code on step 4 above, put the following basic HTML code.

<!DOCTYPE html>
<html lang="en">
<head>
 
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
 
    <title><?php echo $page_title; ?></title>
 
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
 
</head>
<body>
 
<div class="container">
 
</div>
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
 
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
 
</body>
</html>

Enable Image Gallery Lightbox

We’ll include the Blueimp gallery extension so we can view our photos beautifully. Our basic HTML code will look like the following code.

<!DOCTYPE html>
<html lang="en">
<head>
 
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
 
    <title><?php echo $page_title; ?></title>
 
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
 
    <!-- blue imp gallery -->
    <link rel="stylesheet" href="http://blueimp.github.io/Gallery/css/blueimp-gallery.min.css">
    <link rel="stylesheet" href="Bootstrap-Image-Gallery-3.1.1/css/bootstrap-image-gallery.min.css">
 
    <style>
    .photo-thumb{
        width:214px;
        height:214px;
        float:left;
        border: thin solid #d1d1d1;
        margin:0 1em 1em 0;
    }
 
    div#blueimp-gallery div.modal {
        overflow: visible;
    }
    </style>
</head>
<body>
 
<div class="container">
 
</div>
 
<!-- The Bootstrap Image Gallery lightbox, should be a child element of the document body -->
<div id="blueimp-gallery" class="blueimp-gallery">
    <!-- The container for the modal slides -->
    <div class="slides"></div>
    <!-- Controls for the borderless lightbox -->
    <h3 class="title"></h3>
    <a class="prev">‹</a>
    <a class="next">›</a>
    <a class="close">×</a>
    <a class="play-pause"></a>
    <ol class="indicator"></ol>
    <!-- The modal dialog, which will be used to wrap the lightbox content -->
    <div class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" aria-hidden="true">×</button>
                    <h4 class="modal-title"></h4>
                </div>
                <div class="modal-body next"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left prev">
                        <i class="glyphicon glyphicon-chevron-left"></i>
                        Previous
                    </button>
                    <button type="button" class="btn btn-primary next">
                        Next
                        <i class="glyphicon glyphicon-chevron-right"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
 
<script src="http://blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js"></script>
<script src="Bootstrap-Image-Gallery-3.1.1/js/bootstrap-image-gallery.min.js"></script>
 
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
 
<!-- to make photos full view -->
<script>
$('#blueimp-gallery').data('useBootstrapModal', false);
$('#blueimp-gallery').toggleClass('blueimp-gallery-controls', true);
</script>
 
</body>
</html>

Build and Decode Photos JSON link

Inside the DIV tag with a “container” class, put the page title HTML, specify the JSON URL and decode the JSON string.

<?php
echo "<h1 class='page-header'>";
    echo "<a href='index.php'>Albums</a> / {$page_title}";
echo "</h1>";
 
$access_token="your access token";
$json_link = "https://graph.facebook.com/v2.3/{$album_id}/photos?fields=source,images,name&access_token={$access_token}";
$json = file_get_contents($json_link);
 
$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
 
$photo_count = count($obj['data']);
?>

Retrieve Photos

After the $photo_count variable on the code above, loop through the values using the code below:

for($x=0; $x<$photo_count; $x++){
 
    // $source = isset($obj['data'][$x]['source']) ? $obj['data'][$x]['source'] : "";
    $source = isset($obj['data'][$x]['images'][0]['source']) ? $obj['data'][$x]['images'][0]['source'] : ""; //hd image
    $name = isset($obj['data'][$x]['name']) ? $obj['data'][$x]['name'] : "";
 
    echo "<a href='{$source}' data-gallery>";
        echo "<div class='photo-thumb' style='background: url({$source}) 50% 50% no-repeat;'>";
 
        echo "</div>";
    echo "</a>";
 
}

How to Display Likes and Comments?

The feature of displaying the number of likes and comments and actual comments is now included in our PRO source code.

What People Say About This Code?

I’m so glad that other people are delighted by this code, here are some of them!

★★★★★ “The code works beautifully. I had no problems… Great code. DONATE TO THIS SITE!” ~ jdogfantastic

★★★★★ “Ninja Mike, this wonderful tutorial has allowed me to do something totally over my head. Thank you!” ~ Handy

★★★★★ “Hey this is a great and useful script! I’ve managed to change some stuff around as I wanted to show photos from a specific album…” ~ Konstantinos

★★★★★ “Hi Mike, this is really… really… great work dude. You really helped me out today. I added my own twist of incorporating it into AJAX as well. I will post my version of the code.” ~ Paul

★★★★★ “THANK YOU SO MUCH! I’ve been searching and struggling to create a new way for my web customers to organize their own photos on their websites, and this is perfect!!!” ~ Little Doe

★★★★★ “Hi, I”m doing a website for an NGO that helps cancer patients and I’ve used part of your script to display Facebook photos. Great work, btw.” ~ Will

★★★★★ “Hi Mr. Dalisay, My name is Clinton and I’m a front-end designer. I purchased two scripts from you today. Thank you for your time and what a great tutorial and was happy to support your projects.” ~ Clinton

★★★★★ “Thanks for the excellent support…” ~ Horatio

Download Source Code

You can get the source code by following the whole, step-by-step tutorial above. But isn’t it more convenient if you can just download the complete source code we used, and play around with it?

There’s a small fee in getting the complete source code, it is small compared to the value and skill upgrade it can bring you, or income you can get from your website project or business.

For a limited time only, I will give you the source code for a low price. Download the source code by clicking the green buy button below.

FEATURESDOWNLOAD
Manage photos on your Facebook page and website only onceYES
Save time figuring out and coding these features on your websiteYES
Display list of photo albumsYES
Display album coverYES
Display album descriptionYES
Display the number of photos inside an albumYES
Link to an actual Facebook album page (opens in new tab)YES
Clicking a photo album will show a list of photosYES
Each photo are in a square thumbnailYES
Clicking a photo will pop a lightboxYES
Navigate photos using the lightbox’s Next and Prev buttonsYES
Responsive photo albums pageYES
Responsive photos pageYES
Responsive lightbox pop up windowYES
Touch-enabled lightbox gallery (great for smartphone and tablet devices)YES
Bootstrap UI enabledYES
Can show more than 25 photo albumsYES
Can show more than 25 photos inside an albumYES
Photo album cover automatically cropped to a certain sizeYES
No need to make each photo album cover the same sizeYES
Font awesome iconsYES
Share buttons on the photos pageYES
Object-oriented programmingYES

Do you need more reasons to download it?

MORE REASONS TO DOWNLOAD IT
Buy only once, use up to 10 websites and Facebook pages! Yes
No different kind of licenses. Yes
No many different pricing schemes. Yes
No monthly or any recurring fees. Yes
No need to rely on another website to render Facebook photo albums and photos. Yes
No need for codes from other websites. Yes
You can learn more how to code, I love teaching and can give you free tips! Yes
Familiarize yourself with the Facebook Graph API. Yes
Features are constantly improving, and you get it for free. Yes
Completely customizable. Yes

Please provide your Facebook page URL on the message, thanks!

SociableKIT

You demanded it, we built it. A lot of people requested a website plugin version of this Facebook gallery code.

Now it is available. It works no matter what website platform you use. We have tried it in WordPress, Squarespace, Wix, and more.

CLICK HERE to learn more about SociableKIT.

What’s Next?

Today we have learned how to show your Facebook photo albums and photos on your website.

Did you know that you can also display Facebook videos on your website?

Let us go to the next tutorial: How To Display Facebook VIDEOS on Website?

Related Source Codes

Did you know that you can also display other social media data on your website? I’ve created tutorials on them too, see the following:

Social Media Script Tutorials
Display Facebook Page EVENTS on Website
Display Facebook Page PHOTOS on Website
Display Facebook Page VIDEOS on Website
Display Facebook Page POSTS on Website
Display Instagram FEED On Your Website
Display Twitter FEED on Website
Display Google+ FEED on Website

Some Notes

#1 Found An Issue?

If you found a problem with this code, we can solve it faster via Email or FB message, please send me a message via email [email protected], or via our official Facebook page!

Please be more detailed about your issue. Best if you can provide an error message and your test or page URL. Thanks!

Please feel free to comment if you have any questions, suggestions, found something wrong or want to contribute to this code.

#2 Become a true Ninja!

  • 1. Subscribe to social media scripts tutorial news and updates.
  • 2. Be updated about what works and what does not work on social media APIs.
  • 3. Be notified for any related social media API updates.
100% Privacy. We will never spam you!

#3 Thank You!

Thank you for reading our tutorial on how to display Facebook photos on website using PHP!

By Mike Dalisay

I'm Mike Dalisay, a pro web developer since 2010. I love web development. Improving our tutorials and source codes makes me happy. Do you want to suggest an edit to our tutorial? Got something to ask about our source codes? You may use our comments section below or email our team at [email protected]

278 comments

  1. Hi Mike :), Can I via json link download inside “$json_link = “https://graph.facebook.com/v2.8/{$album_id}/photos?fields=” also “place” of the photo?
    Thx for your support.

  2. i found a bug, maybe caused by facebook updates:

    $json_link = “http://graph.facebook.com/v2.3/{$fb_page_id}/albums?fields={$fields}&access_token={$access_token}”;

    for sending tokens with get method you need to use the https://graph… instead of just unsecure http:// protocoll.. maybe you could change this in the tutorial…

    thanks for the tutorial anyway! gave me a good overview to use facebooks graph api. Thanks

    1. @Glodson, thanks for telling us about this! I updated the post above with https:// and v2.8

      You’re welcome and glad our tutorial helped you with your project. Please share our site to one of your friend if you have time, thank you!

  3. I tried the solution, it seems everything is fine but I am getting empty albums, so I tried to figure out that json is coming blank. I tried some solutions, one of them is to configure an app in facebook and give access of user_photos to that app. But it seems options are relevant to creating app to collect photos from others where as my objective is to show my own photo albums on my website. Am I going wrong?

  4. Hello @quickjeff, would you link us to your test URL and FB page ID? Our script only need an access token. What do you mean by OG 2.5, is it the same as FB Graph API v2.5?

    1. Hi Mike, the site is on a dev environment that is gated. As far as the OG 2.5, its the updated Open Graph from Facebook i was referring too. You code was showing to work on 2.4.

  5. @ninjazhai I have used your script before with other client sites. I have a new client site that I have setup an app for using OG 2.5 and for some reason I can load the photos but the album covers do not show. Its not the server since I can upload your stock example and everything works fine. My guess it has to do with the OG 2.5 or some permissions on my clients Business Facebook Page. Any advice would be nice!

  6. @ninjazhai
    The above tutorial gives and error,
    Parse error: syntax error, unexpected ‘221167777906963’ (T_LNUMBER) in index.php on line 33

    This error can be fixed by replacing,

    $fields=”id,name,description,link,cover_photo,count”;”;
    with,
    $fields=”id,name,description,link,cover_photo,count”;
    i guess because you have accidentally retyped (;”) at the end.

  7. I have fixed it to use it with Graph API 2.5, if anyone needs help, please contact me, thanks a lot for the work!!!

    1. @mauricabreraestrada I have 2.5 and cannot pull the cover photos, any help? I saw that the cover_photo is replaced with album_id but not sure if there is another solution? I tried both and still get an array notice.

  8. HI , great code, it works great. But now i have moved to a server that they doesn’t allow file_get_contents, they have Off the allow_url_fopen for some security reasons. Is there any alternative to the file_get_contents?
    Thanks for the code.

  9. I just paid for & downloaded the PRO version. Out of the box I’m seeing this error: Notice: Undefined index: next in C:PATHTOindex.php on line 82

    1. Hello codeview, thanks for purchasing the code! About your issue, would you try to replace this:


      $next_page = $obj['paging']['next'];

      to this:


      $next_page = isset($obj['paging']['next']) ? $obj['paging']['next'] : "";

  10. Hello Is it safe to display the access token in public?? Because the image is displayed only when the access token is provided.

    1. Hello @Zaibatsu, That’s a good question, thanks!

      Here is my answer: it is not okay to display your access token in public. The image src URL will be changed by Facebook during display so it will not show your access token.

      See the cover photo image src URL in the demo…

  11. My code is coming out that the cover_photo is actually an array with the data array, so it doesn’t work showing the $cover_photo because it returns “Array” instead of the ID of the cover_photo.

    “cover_photo”: {
    “created_time”: “2015-02-20T02:37:36+0000”,
    “name”: “Another good year servicing my customers”,
    “id”: “820365984665179”
    },

    1. Hello Greg,

      Yes we noticed that the FB graph api returns different JSON string with newer access tokens. The one above will work with older access token.

      If you have a new access token, you can make it work by:

      change this:

      $cover_photo = isset($obj[‘data’][$x][‘cover_photo’]) ? $obj[‘data’][$x][‘cover_photo’] : “”;

      to this:

      $cover_photo = isset($obj[‘data’][$x][‘cover_photo’][‘id’]) ? $obj[‘data’][$x][‘cover_photo’][‘id’] : “”;

  12. Been looking for a way to implement Facebook Albums integration on a website, & i gotta say, this would have to be by far the most featured plugin available that is actually working up to date with the amount of Facebook Token permissions changes that FB undertakes.
    Love the way of using Light box type load up the photos.
    cant wait to try out the entire code.
    a definite recommendation for download.

    1. Hello @temsulemdor, wow, thanks for the kind words and recommendation! We will continue to update the tutorial and source code to comply with all the FB api updates.

  13. This is really awesome script and Mike is developer who wants to help you to fix errors after you integrated his script in your own site.

  14. I bought the Pro version, but I am getting the same error I got going thru the tutorial:

    Warning: json_decode() expects at most 2 parameters, 4 given in /home/content/29/8748029/html/gallery/level-2/index.php on line 75

    Line 75 reads:
    $obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

    Thanks in advance!

    1. Erin Lima thanks for purchasing the code… I replied to you on Facebook…


      // replace this
      $obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

      // for those using PHP version older than 5.4, use this instead:
      // $obj = json_decode(preg_replace('/("w+"):(d+)/', '\1:"\2"', $json), true);

  15. Hello- I purchased the pro version and was wondering if there was a way to load all gallery images at once rather than paging. I know the Graph API will only return 100 results at a time, hence the need for paging, but I’ve ben unsuccessful in figuring out a solution using the total number of images in the gallery vs how many have loaded thus far using javascript and php.

    I only ask as because if the user has not completely scrolled to the bottom of the page to load all the paged images, the lightbox will not show all the photos in the gallery.

    Thanks for the great script and your help!

  16. good evening… i have a question for you about your (the pro one that i have I bought)
    why the images are resized to 720x480px while on fb they are 2048×1366?? how is possible to have the full size image?

    thank for your help.

    Gianluca

  17. Great tutorial, just what I was looking for. Can I ask though, when opening the gallery it only shows 25 images on the layout view and the pop up, despite there being more on Facebook. Is this a limitation of the basic code and is it featured in the pro version or am I missing something? Thanks!

  18. Just a note if other people has the same problems, please be more detailed about your issue. Best if you can provide your test URL, FB page URL and other details. Thanks!

    1. Hello @mglinn, are you on shared hosting server? Sometimes a shared hosting is blocked by Facebook because there were too many requests on that server…

      Also, you have to get your access token..

      1. Hi, I test it in my vps and now I change to digital ocean, but file_get_contents error occur after two days because of too many users :) .
        And I want to know how to add access token ?

        $json_link = “http://graph.facebook.com/{$fb_page_id}/albums?fields=id,name,description,link,cover_photo,count”;
        Do I need to add at the end of the graph url ?
        Thank you for your reply .

      2. Recently bought your script. Can you provide quick tutorial for creating fb app and token for us in Download file on sellfy?
        How can I avoid this error with .htaccess on shared hosting? Just tried this:
        php_value allow_url_fopen On (nothing happens)
        allow_url_fopen=on (gives 500 internal server error)

      3. Put it in index.php on line 72.

        $access_token=”AppID|AppSecret”.

        The same error, nothing happens.

  19. I Purchased pro version of this is think it should be noted more clearly; This will ONLY work with specific types of FB pages. Different pages have different permissions, these permissions effect whether or not this code will work. An example of a VALID type of page can be found in the following tutorial from this site; https://www.codeofaninja.com/2013/02/how-do-you-start-facebook-page.html

    In my case, my client created a new FB account but the page type he had selected prevented this code from running. I spent time trouble shooting and thought I’d share with anyone else that might experience the same. Typically I was seeing errors related to Tokens/permissions etc.

    1. Hello @Tburton, sorry for the trouble but as mentioned in the source code overview, it’s for Facebook fan pages (which have publicly available data), I apologize for not mentioning it more clearly. By the way, which type of Facebook page your client did create? And what exactly the token related issue you encountered? Thanks for your time!

  20. I found that some of the album have error :

    eg .
    Fatal error: Uncaught Exception: An unknown error occurred thrown in /home/mjd/public_html/mysite/fb-sdk/src/base_facebook.php on line 1340

    1. Hello @mglinn, we’re not using the fb sdk in the tutorial above… Please follow the tutorial to make it work, or you can just download the code if you want…

      1. @mglinn, we already have that on the “photos” page, you can see this effect if you download and use the source code for albums with many photos… I’m working on the “albums” page “load more” feature… Thanks for your suggestion! :)

  21. I don’t see anyone else having this problem, but I’m having a 500 Internal Server Error while trying to run this code… Page is: http://zombieleader.com/gallery/test/ Funny thing is, I have this exact code working beautifully on another page… I’ve tried changing the PHP permissions for the page in question, but still no luck. Any help would be most appreciated!

    1. @mikavlimki and @KyleP555 , would you show us your code? So we have some clues debugging it..

  22. Hi its a nc script thank you for your code but my issue is it is working for some ownerid not for everyone why so? is that a permission issue ? if yes how can i fix this ?

  23. Ninja Mike, This wonderful tutorial has allowed me to do something totally over my head. Thank you! Can you show an example of how to change the code to exclude certain albums, or only include select albums from the FB account?

    I am not sure what to put here:

    $fql = “SELECT
    aid, cover_pid, name
    FROM
    album
    WHERE owner=****************”;

    I have tried lots of things, but just blow it up.

  24. Hi Mike,

    How do I alter this so that a user can upload an album from Facebook and then view it on my website automatically?

  25. Hey this is a great and useful script! I’ve managed to change some stuff around as I wanted to show photos from a specific Album but there is a problem. If I leave it to “ORDER BY created DESC” it returns a limited amount of photos from the album, on the other hand if you go for ASC it will return all of them, any idea how can we make a DESC but grabbing everything ? Plus i’m getting 2 errors for ‘headers already sent’, anyway possible to fix that ( i have no idea what it is ). Thanks in advance! :)

  26. Hello,

    Many thanks for such an awesome script. I have been using for over a year now without any problems. However, recently, I have come across a problem, none of my albums nor images are being shown on my website. Could you please assist me when you are available to do so?

    Thank you in advance.

    1. Please do help as I am using the script on a nursery website for parents to view and they are now unable to view it. I would post my website link but I am not sure if it is allowed.

      Thanks

      1. could it possibly be because of privacy settings changing on facebook page? is your page set to public?

  27. Excellent script. Thanks so much. Is there a way I can link an image to take the visitor to facebook so they can tag the photo? Or allow them to tag on our web page?

  28. this is great. I have it working but now the facebook page I am using has a ton of pictures… is there a way to paginate the images once you open an album?

  29. This might be a dumb question, but if I already have an app do I have to create a new one for each of these new features? Or can I continue to use the same key and secret code for these. They are for the same website, so the URL won’t change.

  30. Hello, why in yahoo small business hosting won’t work? On localhost xampp working everything but when i upload it to yahoo account won’t work :/

    1. Could you please show us how you made this ?
      I’ve tried several solutions, but nothing happenned.

      It would be nice from you !

      Thanks in advance.

      1. I tried to change this part
        __________________________________________
        $fql = “SELECT
        aid, cover_pid, name
        FROM
        album
        WHERE owner=151037504938143”;
        __________________________________________

        into this
        __________________________________________
        $fql = “SELECT
        pid, src, src_small, src_big, caption
        FROM
        photo
        WHERE aid=151037504938143_1073741825”;
        __________________________________________

        Does someone can help me to have it working ?

  31. i found error of

    —Fatal error: Uncaught CurlException: 60: SSL certificate problem, verify that the CA cert is OK. Details:
    error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
    thrown in C:xampphtdocssitejQuery-lightboxfb-sdksrcfacebook.php on line 622
    plz give the solution.

  32. i face some error in this code.there is error of uncaught exception .

    Fatal error: Uncaught Exception: 190: Invalid OAuth access token signature.
    thrown in C:xampphtdocssitefb-sdksrcbase_facebook.php on line 1254.
    plz give me the answer of this prob.

  33. Hi Mike,

    I am using Pull_Facebook _data code which is given by you but don’t run it show this Error please guide me as soon as possible.
    ERROR———

    Fatal error: Uncaught CurlException: 60: SSL certificate problem, verify that the CA cert is OK. Details:
    error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
    thrown in C:xampphtdocspull-facebook-datafb-sdksrcbase_facebook.php on line 886
    ————-

    thanks

    sumit kumar

  34. Hi Mike,
    Im getting fatal error at run time

    Uncaught exception ‘Exception’ with message ‘Facebook needs the CURL PHP extension.’ in C:xampphtdocsFacebook_Photofacebook.php:4 Stack trace: #0 {main} thrown in C:xampphtdocsFacebook_Photofacebook.php on line 4

  35. How would I modify this script to display only the photos from one album, instead of all albums?

    It works great, I just need to show photos from one album though.

    Thanks in advance.

  36. Hi. I like that app. and wanted to include it in wordpress. It works smoothley until I click on one album. The following link will not work ..

    Example link: index.php?action=list_pics&aid=221167777906963_68635&name=Android

    So the fotos in the album aren’t shown.

    Any suggestion or experience in handling this with permalinks ..?

    Thanks
    Fred

  37. Hi, Thanks for your code. I successfully pulled a random members photo from our open group page. However, it takes time to load. Maybe I didnt put the right code or something. Im just an average PHP/FQL programming so bear with me.

    Here is out website: http://www.chagalog.org/

    If you could create a new tutorial on how to pull members photo from an open group page that is fast loading, that would be great!

    Thanks again

  38. Hey,

    I have a question. Basically if you have a show_photos page with say 3 pages, and you click on a picture on first page and press the next button in the modal window/pop-up only the photos in the first page will be displayed.

    In other words, if you have 3 pages you cant view each picture in all of the pages via the modal popup.

    What’s the way around this?

    Thank you :)

  39. Still not working for me either :( it was working perfectly to begin with. I didn’t alter a thing but suddenly, no photos. I’ve also created a new FB app and tried that but still, nada.

  40. Hi Mike
    is it possible to display the like button beside the photo ? I was taking to add the like_count in the FQL , doesnt work. I am trying to add a poll photo by like on my webpage.
    Thanks ,,
    looking forward to your voice
    fai

  41. I want to go to an album and display on my website only the one(s) I click not all, how this code will vary. What I can not do is retrieve the id of one clicked (selected) photo.
    Thanks

  42. Mike how do you limit the results of the photo gallery to < 7 per row? I need it to be 4 images per row. Thanks!

  43. jQuery NOOB needs assistance.

    Hi~ I’m working on a site for a non-profit animal rescue and I’m hoping to use your script to pull in pics from our FB page (http://facebook.com/LilOrphanHammies )

    The page I would like them to pull to is: http://lilorphanhammies.org/scrapbook

    I have not yet integrated Lightbox, but I got the impression from everything above that this is the “icing on the cake” as opposed to a mandatory item for function.

    I’ve entered our App ID and Secret. Can anyone tell me what I’m missing/ doing wrong?

    Thank you!

    1. Hmm. I’ve tried creating a new FB app, just in case there was a problem with the first one, but I still can’t get this to work.

      Any ideas?

      Thanks!

    2. Still no errors, but it breaks my PHP template and causes an otherwise validating page not to validate. The inclusion of this script causes div’s that were closed to read as unclosed tags. Any ideas?

      Thanks again!

  44. Hi there, i have to tell you that something is wrong with this code, at first everithing was working just fine, but for several days in my gallery thumbnails of album is not showing. I have went to your page, see where have I mistaken, and on your demo that doesnt work either.. so, did facebook changed something or what is happening?

    Daniel

  45. I had this code working fine on a site, thanks for providing it. But, now the gallery section on the site is just blank. I’ve checked the facebook page owner hasn’t deleted their albums. Puzzled. Has anyone else using this reported similar problems?

  46. GOT IT!

    So replace line 28 (this line: $fql = “SELECT aid, cover_pid, name FROM album WHERE owner=188166104626524”;)

    WITH THIS:

    $fql = “SELECT aid, cover_pid, name FROM album WHERE owner=188166104626524 AND name<>’Wall Photos’ AND name<>’Cover Photos’ AND name<>’Profile Pictures'”;

    1. i’m trying to do the same thing with no luck. anyone found the correct solution? i believe you have to run multiple queries to filter, but i am not sure.

    2. $fql = “SELECT aid, cover_pid, name FROM album WHERE owner=xxxxYOU ID xxxxx AND name<>’Wall Photos’ AND name<>’Cover Photos’ AND name<>’Profile Pictures'”;

      Replace this in to line 28 of the index.php it get rid of profile pics, wall photos & cover photos

  47. Hey mike,

    Nice code, but i cant figure out how to select only 3 albums out of 30, without having to define 27 of them. That seems a bit ineficient to me xD

    Any clues?

  48. Where should my facebook appID link to?? I have tried my facebook landing page appID and secret code that doesnt seem to work. My question is when i create an appID where should i reference it to?

  49. Great code!
    I’ve modified it to load individual facebook pages (as in your personal one) but I’m encountering an issue where if the page fully loads the clicked album isn’t visible, but if you press it before its finished loading it works fine. Any help/tips?

    http://www.xkarlbriggsx.co.uk/gallery.php it links to the facebook app, requires authorisation, loads the photos from the users gallery, but as mentioned stops being clickable once its loaded!

  50. Nevermind I used your suggestion to filter out 4 phantom albums. What I think this is could be deleted albums still in facebook’s fql databse???? Some of the titles seemed like older, and crappier names to existing albums. I’ll ask the original owner of the fan page as im doing this for somebody. Maybe there’s an extra column to filter out in the fql query like “status != deleted” or something… who knows maybe a bug? If you could try in your own demo, delete and recreate an album and see what shows up?? Ill try this on my own time but it wont be any time soon. Thanks again dude!

    1. Hi Paul, I’m glad it works for you. I haven’t looked at that instance yet (I may find time), but maybe, the deleted albums isn’t instantly deleted on facebook’s servers. It might take some time before it will be completely removed. Anyway, what is important now is you can filter out what albums must be shown on your client’s site. :)

  51. Hi Mike, this is really… really… great work dude. You really helped me out today. I added my own twist of incorporating it into ajax as well. I will post my version of the code. However I am having the same problem as two other people who commented here. The problem also existed when using the original form of your code without the ajax.

    …it’s the phantom albums. I have several blank albums showing up and it’s really annoying. See under the gallery section @ http://www.havanahookah.net/index2.php

    thanks in advance…
    Paul

    1. Part 2 ;)

      photos.php =
      ||||div style=’font-size: 16px; font-weight: bold; margin: 0 0 10px 0; color: #FFF;’>
      This album is synchronized with the Havana Hookah
      ||||a href=’https://www.facebook.com/HavanaHookahLounge/photos’ target=”_blank”>
      Facebook Photo Album.
      ||||/a>
      ||||/div>

      ||||?php
      //include the facebook PHP SDK
      require ($_SERVER[‘DOCUMENT_ROOT’].’/fb-sdk/src/facebook.php’);

      $facebook = new Facebook(array(
      ‘appId’ => ‘ENTER YOUR OWN APPID’,
      ‘secret’ => ‘ENTER YOUR APP SECRET’,
      ‘cookie’ => true, // enable optional cookie support
      ));

      //defining action index
      isset( $_REQUEST[‘action’] ) ? $action = $_REQUEST[‘action’] : $action = “”;

      //if there’s no action requested
      if( $action == ”){
      echo “”;

      $fql = “SELECT aid, cover_pid, name FROM album WHERE owner=########### AND name != ‘November 22, 2011’ AND name != ‘November 17, 2011’ AND name != ‘November 16, 2011’ AND name != ‘SEPT 11 2011’ AND name != ‘NORRIDGE TOBACCO HALLOWEEN PARTY OCTOBER 29 2011′”;
      $param = array(
      ‘method’ => ‘fql.query’,
      ‘query’ => $fql,
      ‘callback’ => ”
      );
      $fqlResult = $facebook->api($param);
      echo “||||div class=’galcenter’>”;
      foreach( $fqlResult as $keys => $values ){

      //we will do another query
      //to get album cover
      $fql2 = “select src from photo where pid = ‘” . $values[‘cover_pid’] . “‘”;
      $param2 = array(
      ‘method’ => ‘fql.query’,
      ‘query’ => $fql2,
      ‘callback’ => ”
      );
      $fqlResult2 = $facebook->api($param2);
      foreach( $fqlResult2 as $keys2 => $values2){
      $album_cover = $values2[‘src’];
      }
      echo “||||div style=’padding: 10px; width: 150px; height: 170px; float: left; color: #FFF;’>”;
      echo “||||a onclick=’fetchAlbum(“” . $values[‘aid’] . “”, “” . $values[‘name’] . “”)’ style=’cursor: pointer; ‘>”;
      echo “||||img src=’$album_cover’ border=’1′>”;
      echo “||||/a>||||br />”;
      echo $values[‘name’];
      echo “||||/div>”;

      }
      echo “||||/div>”;
      }

      //when the user clicked an album
      //it will show or list all the pictures
      //on that album
      if( $action == ‘list_pics’){
      isset( $_GET[‘name’] ) ? $album_name = $_GET[‘name’] : $album_name = “”;

      echo “||||div style=’color: #FFF;’>||||span style=’cursor: pointer; text-decoration: underline; color:#0033FF;’>||||a onclick=”loadPage(‘photos’)”>Back To Albums||||/a>||||/span> | Album Name: ||||b>” . $album_name . “||||/b>||||/div>||||br />”;
      echo “||||script language=javascript>scroll(0,0);||||/script>”;
      $fql = “SELECT pid, src, src_small, src_big, caption FROM photo WHERE aid = ‘” . $_REQUEST[‘aid’] .”‘ ORDER BY created DESC”;
      $param = array(
      ‘method’ => ‘fql.query’,
      ‘query’ => $fql,
      ‘callback’ => ”
      );
      $fqlResult = $facebook->api($param);

    2. Part 3 :o

      //so that jQuery lightbox will pop up
      //once the image was clicked
      echo “||||div id=’gallery’ class=’galcenter’>”;

      foreach( $fqlResult as $keys => $values ){

      if( $values[‘caption’] == ” ){
      $caption = “”;
      }else{
      $caption = $values[‘caption’];
      }

      echo “||||div style=’padding: 10px; width: 150px; height: 170px; float: left;’>”;
      echo “||||a href=”” . $values[‘src_big’] . “” title=”” . $caption . “”>”;
      echo “||||img src='” . $values[‘src’] . “‘ style=’border: medium solid #ffffff;’ />”;
      echo “||||/a>”;
      echo “||||/div>”;
      }

      echo “||||/div>”;
      }
      ?>

      ||||!– jQuery lightbox include script –>

      ||||script type=”text/javascript” src=”../jQuery-lightbox/js/jquery.js”>||||/script>
      ||||script type=”text/javascript” src=”../jQuery-lightbox/js/jquery.lightbox-0.5.js”>||||/script>
      ||||link rel=”stylesheet” type=”text/css” href=”../jQuery-lightbox/css/jquery.lightbox-0.5.css” media=”screen” />

      ||||!– END JLIGHTBOX –>
      ||||script type=”text/javascript”>
      $(function() {
      $(‘#gallery a’).lightBox();
      });
      ||||/script>

      …I hope this helps. Sorry if this is all over the place, I did it over a month ago and I just retraced my steps to try and reply with something. It’s not perfect but does the job as needed right now. I never got an email notifying me of your response or I wouldve replied back in April. I feel I owe the author of this tutorial that much :)

  52. The code works beautifully. I had no problems except for one. When I uploaded it and changed out the APP ID and Secret everything was working. I located the facebook Page ID and swapped it out too. Everything was fine till I clicked on an album. “File not found” Turns out that renaming your file “index.php” will render the program unusable unless you fix line 53 ( echo”<div><a href=”RENAMEDFILE” . . ) Works now. Great Code. DONATE TO THIS SITE!

  53. Hello! love the script, however I am getting phantom albums that are being created. If i create a new album in facebook & upload 1 picture, it displays in the script normally. However, if I have more than one picture, your script creates a phantom album with the same cover photo, but it’s labeled untitled & has no pictures in it… any advice?

    1. I followed your code exactly and don’t have any errors, aside from this one… it’s really bugging me. The only thing I can think of is that possibly it’s an issue with facebook? As this only happens with my newer albums, and not the older ones.

      Do you have any idea as to why this is occurring Mike?

      If you take a look at the demo, it’s generating two untitled albums, with no pictures in them… advice?

    1. Hi @Alex, Profile Pictures are different from you Wall Photos. If you want to unselect an album you have to do something like:

      SELECT aid, cover_pid, name FROM album WHERE owner=your_page_id AND aid != id_you_dont_want_to_select

  54. Hi Mike, thanks for all your hard work. I’m searching for a way for group members on FB to be able to post a public album to the group and allow other members (non-friends) to be able to tag or comment on the photos in the album. Members can post an album, but cannot comment on the photos. Any suggestions? Here’s a link to one of my public albums so that you can see what I mean… https://www.facebook.com/media/set/?set=a.10150789080685968.499526.781045967&type=3&l=2defbbcec4

    Thanks for any suggestions!
    Cheryl

  55. Hey Mike..thats a great piece of code ..i made a small implementation of it here..

    http://goo.gl/Ti6yo

    thats just for a sample..

    and Mike the issue i have is with the thumbnails.. can’t I get all the thumbnails in one size.. ‘coz they look a bit unnatural when they are of different sizes..

    Please Help me out . Thanks in advance …

    Rathan

    1. Hi @Rathan, regarding the thumbnail size, that can be fixed using CSS. You may try this method: define the size of your thumbnail in a div then use something like overflow:hidden

  56. Hey Mike, thanks for the great script.

    I have it implemented, and I can plug in just about any facebook id to get their feed, except the one I am trying to get. Is there something in particular I need to do to the feed on facebook’s end to ensure it shows up?

    Any help is greatly appreciated.

    Here is the page I’m trying to put it on:
    http://dev.bigshift.com/music-iframe/

    with this ID:167626859995709

    Thanks.

  57. Hello, thanks very much.
    I was wandering if there is a way to limit the query to the latest album, for instance to show only the last 12 albums?
    Thanks again…

  58. Is it feasible to use this code against a user’s profile rather than a page — if the app requested the appropriate permissions: user_photos,friends_photos ?

    Mike — Any ideas? on this

  59. Hi, I have a problem, i download file Fb-SDK/src/facebook.php and upload to my localhost to folder “fb-sdk/src/facebook.php”. I start /localhost and select folder in browser and browser wrote message error “Parse error: syntax error, unexpected ‘]’ in C:ComplexWebServerhttp_docsjfb-sdksrcfacebook.php on line 940”. Whre is problems?

    Script from 940 line: hashComments:b,cStyleComments:b,multiLineStrings:b,regexLiterals:b}),B={};h(da,[“default-code”]);h(y([],[[“pln”,/^[^]*(?:>|$)/],[“com”,/^<!–[sS]*?(?:–>|$)/],[“lang-“,/^<?([sS]+?)(?:?>|$)/],[“lang-“,/^<%([sS]+?)(?:%>|$)/],[“pun”,/^(?:<[%?]|[%?]>)/],[“lang-“,/^]*>([sS]+?)</xmpb[^>]*>/i],[“lang-js”,/^]*>([sS]*?)(</scriptb[^>]*>)/i],[“lang-css”,/^]*>([sS]*?)(</styleb[^>]*>)/i],[“lang-in.tag”,/^(</?[a-z][^<>]*>)/i]]),”default-markup,htm,html,mxml,xhtml,xml,xsl”.split(“,”));
    Where is a problem/s? Can you help me pls ? Thank!

  60. It is possible to get the photos of users whom you are friends with. Add the following lines before the line

    // defining action index
    if ($facebook->getSession()) {
    echo “You have a facebook session for this app”;
    } else {
    echo “You need to login first – “;
    echo ‘Login‘;
    }

    Whatever URL you are using for testing, this needs to be added in the Website section of the facebook application settings. AAfter clicking on Login, your browser will be redirected back to the same page, upon which the login button now disappears as you are logged into facebook with respect to the application.

    Then change your search to the id of the user whom you are interested in. There is no longer a restriction to just pages

  61. Great knowledge you have shared with us and before read your post i was unaware about it and thought that it is impossible for me to do it, but after read your post i am feeling that it is easy and it will help me a lot.

  62. Hi Mike,
    This is an awesome script, if I only can get it to work!!!!
    I’m using wysiwyg to do my webpage and I’m using jQuery to make a photoalbum thats on my server how ever when I’m trying to use your script as is just to see if it works i get the following error:
    Fatal error: Uncaught Exception: 190: Invalid OAuth access token signature. thrown in D:Hosting6940775htmlFotoalbumFacebookfb-sdksrcfacebook.php on line 515
    I have 2 problems, one I’m not a programer I’m a golfpro and I have up to now put a link to the facebook pictures on my webpage, but this is very timeconsuming and requieres constant updates of the webpage. It’s so easy just to upload pictures directly to facebook but there is where my second problem comes, most of my clients are 60+ and they dont have facebook. I’m desperate for help and I would be more than happy to pay to get this solved as it is very important to me and my company.
    Sincerely,
    Manuel.

  63. I’m getting this, any idea’s?

    Fatal error: Uncaught Exception: 102: Session key invalid or no longer valid thrown in /home/readys/public_html/apartmentgroup/floritas/gallerytest/fb-sdk/src/facebook.php on line 515

  64. hello,
    i would like to show in a jquery slider ( into a .php file for my Facebook page) images from a selected Facebook page album.
    I can’t find the solution

  65. Very nice work mike it helps to build a Media RSS feed hope it gets the video url int he album too that would be over hit
    should work with public groups ?

    Thank you very much

  66. Hi Mike,
    Thank you for all the extremely helpful posts you have written and initiated.
    I am struggling with my first facebook app and your code is very helpful though …
    I can’t access my albums, with my app id and secret id I can view your and funky cakes albums but using my owner id: 100002604335685
    I receive the error “Fatal error: Uncaught Exception: 102: Session key invalid or no longer valid thrown in “.
    I haev made my albums public is there something else that I am missing that you cann see?
    Much appreciated,
    Moz

  67. Code is working great!

    Is there any way to display only 1 album? Basically display the page as if an album was already opened.

    I want to split up the photo albums on my website.

  68. Hi I’m trying to get a loading bar working and used the code from your paginating data tutorial as you suggested in a comment in july. It works on the initial page load, but if you click an album it reloads the whole page instead of opening the album. Any ideas to get around this???

  69. hello Mike,

    great work. though i have not seen it at work

    i have this error:

    Fatal error: Uncaught Exception: 102: Session key invalid or no longer valid thrown in C:wampwwwomafoundationphp-sdkbase_facebook.php on line 1039

  70. Fantastic script!!!!!!
    I was going crazy to find a method to display in my website the facebook pics!
    But..i have one question..can i show also albums of people or group? how do i?

  71. I’m getting the following error – Invalid or no certificate authority found, using bundled information

    please let me know what I need to do to fix this problem.

  72. is there a way to also pull the LIKE and SHARE buttons as well from a given photo/album as well? Just curious as it’d be more beneficial to not have to take a person away from my site in order to use the social aspects of a facebook album.

  73. hei, i have problem like:

    Fatal error: Uncaught exception ‘Exception’ with message ‘Facebook needs the CURL PHP extension.’ in /var/www/fesbuklike/sdk/src/base_facebook.php:19 Stack trace: #0 /var/www/fesbuklike/sdk/src/facebook.php(18): require_once() #1 /var/www/fesbuklike/gallery.php(11): require(‘/var/www/fesbuk…’) #2 {main} thrown in /var/www/fesbuklike/sdk/src/base_facebook.php on line 19

    tell us what problem this like??

    thx.

  74. Hello Mike!

    Seems to be pretty simple. I would try out with your App ID before starting with mine. But I got an error (Fatal error: Uncaught Exception: 190: Invalid OAuth access token signature. thrown in /home/antimon/public_html/beta/fb-test/fb-sdk/src/facebook.php on line 515). I have just uploaded your full package here, without no changes: http://beta.anti-monkey.com/fb-test/. Any idea what could went wrong?

    thanx :)

  75. Thanks for the reply Mike. Anonymous is me too btw, forgot to use the name/url option. Sorry for the confusion.

    Anyway, here’s the query I used:

    “SELECT pid, aid, owner, src, src_big, src_small, link, caption, created FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner = 205702516132944) ORDER BY created DESC”

    I used the COAN dummy page as per the demo to test it out.

  76. @Anonymous: I’m afraid but I don’t have any idea on that error, sorry

    @JP: I think yes, you have to select all album ids first then loop through the photos table echoing all photos from those album ids.

    @arcadio813: I think its a yes too, you just have to get the ids of your fb page albums then use those ids to query your albums. something like multiple: …WHERE aid = ‘your_album_id’, other way would be: …WHERE aid IN( ‘album_id_1’, ‘album_id_2’, ‘album_id_3’)

    @Anonymous: could you post your query on selecting images and the link to your fan page? hmmm maybe you uploaded duplicate images on your fan page and that was fetched by our script

  77. I modified the code to display all photos from a fanpage.

    Managed to work it out,but it’s showing many duplicates of the same images. Any idea why?

  78. Hi Mike,

    I have a couple of company pages on FB, is it possible to display selected (with aid) albums from these pages too, as at the moment only my albums are displayed.

    Cheers

  79. Hi Mike,

    I have a couple of company pages on FB, is it possible to use your script to display single albums from these pages too, as at the moment only my albums are displayed.

    Cheers

  80. Thanks for this wonderful script, it works perfectly!

    One question though, is it possible to display all photos from all albums on a single page?

  81. I keep getting this error – i called my host and CURL is enabled

    syntax error, unexpected T_NEW in /homepages/6/d126613682/htdocs/drink/gallery/facebookpix/fb-sdk/src/facebook.php on line 4

  82. Hello,

    I go on the “download” button, but then I cant download the package.
    Do I miss something?
    Which files do I need to downlad?

    This is an awesome script BTW.

  83. This works awesome…however is there a way to do the same with a profile not a fan page?

    There would be a tremendous amount of interest if that can be done

    Mark

  84. Hi, me again :) The large photos in the script are 720px wide as in facebook’s photo display page. Is it possible to show instead the high resolution version of the image (the one available by clicking ‘download’ on facebook)?

  85. Hi this looks just like what I need for my website.However I’m getting this error:

    Fatal error: Uncaught Exception: 190: Invalid OAuth access token signature. thrown in C:wampwwwfb-sdksrcbase_facebook.php on line 668

    Any ideas why?

  86. I think your server has some issues, it is not given enough time to connect with facebook server. Try to modify your facebook.php with your editor, and find this code (probably line 89)

    public static $CURL_OPTS = array(
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 60,
    CURLOPT_USERAGENT => ‘facebook-php-2.0’,
    );

    Modify CURLOPT_CONNECTION to increase its value to, 30 or higher.

    CURLOPT_CONNECTTIMEOUT => 30,

  87. I enabled curl in the ini file, however, i still get the same message.

    Fatal error: Uncaught CurlException: 6: name lookup timed out thrown in /var/www/vhosts/socialmediamove.nl/httpdocs/ht/events/fb-sdk/src/facebook.php on line 622

    What am i doing wrong?

  88. Hi i got an error opening index.php.

    What did i do wrong?

    Fatal error: Uncaught CurlException: 6: name lookup timed out thrown in /var/www/vhosts/socialmediamove.nl/httpdocs/ht/fb-sdk/src/facebook.php on line 622

  89. Ooooh! That looks good, i’ll have a bash at it
    and see what happens! :D

    Seriously, I can’t thank you enough for the original script, and your quick resonse to my question too. Cheers :)

  90. Hi Mike,

    I got this working on my page and want to thank you , i’ve been searching for ways to get content from our Facebook fan page for ages!

    Maybe you can answer a question for me?…

    When I load my page the browser shows ‘connecting’ but the page is not shown until all the data has fetched from facebook. I realise there are a lot of images being pulled from my gallery so it will take time, but i’m taking about 10 – 20 seconds of inactivity.

    Would there be a way to activate the script once the page has displayed, that way i could add a pre-loader or notification so users understand there will be a delay?

    My page is http://www.thebetaspace.com if you want to see it in action. Thanks :)

  91. Hi Mike!

    Very cool stuff. Yours is the only thing like it I have found so far. Have you experimented with Events, Notes, etc? Just curious.

  92. Hi guys, I also tried and experimented this script with my FB profile pictures, unfortunately, I think this method is not suitable for fetching FB profile pictures. This method is only for Fan Pages.

    I could post about how to fetch your FB profile pictures. Please subscribe via RSS or email for updates. Thanks.

    1. if you want to use pics from a user account you need to create login so you can authenticate that user, remeber if your albums are public like fan pages you are good to go but if you have set any type of restrictions then authentication is needed.

  93. @anonymous_1: hmm i think you can use any caching techniques to do that on your server (e.g. http://memcached.org/)

    @anonymous_2: i think i didn’t post MY app_id and app_secret. can you give those ids you used?

    @singapore web design: I will post more about that on my future posts.

    thanks for you appreciation. :)

  94. Hi Mike,

    this is great!
    question though, when i use my own App_id and App_secret my albums/pictures doesn’t show up. but when i use your App_id and my App_secret it shows your albums/pictures. what do i need to do with my facebook account? any Ideas?

  95. This is an excellent piece of work! However, one of the drawback could be speed… What about a script that replicates the Facebook archive locally?

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top