Use Picasa RSS Feed to show album on my own website

Recently I've moved the web albums of my kids from my own webserver to Google Picasa. But... I wanted to keep my nice javascript based carousel :-)

In the current code I already had some PHP-code that creates the content of the carousel using an array. Now I added two new features in the 'website'.

  1. Config files

  2. Downloading the RSS (XML) feed and cache it

  3. Extract the URLs with the photos from the XML feed.

1. Config files

One 'global' config:

 $cacheTTL = 60;

Per album I've a config.php in that directory, so for example we've the following content:

  $AlbumDescription="Rick de Rijk";

2. Download the RSS (XML) feed and cache it:

# Code that takes care of the caching
if (!(file_exists($xmlFile) &&
    (time() - $cacheTTL < filemtime($xmlFile))
  )) {
    $data = file_get_contents($xmlURL);
    $f = file_put_contents($xmlFile, $data);

3. Extract the URLs with the photos from the feed

$foto_array = array();
$xml = new SimpleXMLElement($xmlFile, null, true);

$urls = $xml->xpath("channel/item/enclosure/@url");

foreach ($urls as $image_url)
  array_push($foto_array, $image_url);

That's all :-)