Facebook -> WordPress: fotobook, automatic update

Hi guys,

another modification for the fotobook plugin for facebook is the ability to automatically update albums based on a timer, which is great if you casually add photos to the facebook albums, but don’t remember to update them in wordpress, you can actually get the system to update itself.

Firstly, it’ll only work on albums you have already selected to show in the wordpress blog, so if you add a new album, you’ll still have to manually add that through the wordpress blog administration panel.

Secondly, open the fotobook.php file from the fotobook plugin in your favourite text editor and search for the this function

“function fb_display_main”

You’ll find it around line 930.

above it, add the following NEW function

function fb_periodic_update()

$current = time();
$timeout = 300;

$_SESSION["fb_update_timeout"] = $current - $timeout;

if(($_SESSION["fb_update_timeout"] + $timeout) <= $current) { $_SESSION["fb_update_timeout"] = $current; $facebook = new FacebookAPI; if($facebook->link_active()) $facebook->update_albums();

Then at the top of the function fb_display_main(), do this

function fb_display_main($content) {

....the rest of the function don't touch it......

now whenever you open the fotobook albums page, every 500 seconds, it’ll refresh from facebook the photos you have in all the albums.  I tried it myself and it works beautifully!

So, I hope you have fun modifying wordpress plugins! Keep the flame burning!

8 thoughts on “Facebook -> WordPress: fotobook, automatic update”

  1. Automatic updates are possible without this hack using a cron job, which is preferred since it’s done in the background. The cron URL is shown on the bottom of the Fotobook Options page. Using this method your users will have about a 5-20 second delay loading your site every 500 seconds, depending on how many accounts and albums you are pulling.

  2. Hi Aaron,

    the reason for the hack is that my host doesnt allow anyone to touch the cron, so my assumption was that because I am not allowed to set cron jobs, the functionality won’t work.

    therefore I had to setup a system where it would every 500 seconds update the photos, I could put it higher, but I just chose to set it a little lower because I was testing it out.

    although this only affects the page that shows the albums, so it’s not very intrusive even if it does cause any delay, on my host, there is almost no difference between an update refresh and a non-update refresh of the page, perhaps facebook is fast enough when it comes to 1-2 accounts, but perhaps it’s a larger delay when you start putting 50 accounts?

    although I dont think fotobook can do multiple accounts without the previous hack I did anyway, right? it’s for one account only? is that right?


  3. sorry if the method doesnt exist, I can’t help you, it exists in the version I downloaded from the website, so I can only imagine you are making a mistake somewhere, try reading the information again and starting from scratch to see if that helps.

  4. @ Aaron: What’s your “command to run”-line on the cronpage?

    /usr/local/bin/php /home/xxxxxx/public_html/wp-content/plugins/fotobook/cron.php?secret==xxxxx&update

    won’t work for me: error with the arguments…

    I Hope you can help? Thx!

Leave a Reply

Your email address will not be published. Required fields are marked *