flickr slideshows

The next part of the puzzle is to pull together a bit of javascript that will cycle through a list of given urls and display each for a few seconds in an endless loop. So with a bit more twiddling, I have the following perl script to generate the proper java:
[code lang=”perl”]
#! /usr/bin/perl -w

# from http://linuxgazette.net/110/oregan.html

use Flickr::API;
use Data::Dumper;
use XML::Parser::Lite::Tree::XPath;

my $api = new Flickr::API({’key’ => ‘mmmmpgh’});
my $user = “sclrr_pictures”;
my $response;

$response = $api->execute_method (’flickr.people.findByUsername’,
{ ‘username’ => $user, });

$xpath = new XML::Parser::Lite::Tree::XPath($response->{tree});
@username = $xpath->select_nodes(’/user’);
$userid = $username[0]->{attributes}->{nsid};

$response = $api->execute_method (’flickr.people.getPublicPhotos’,
{ ‘user_id’ => $userid, });

$xpath = new XML::Parser::Lite::Tree::XPath($response->{tree});

# url format at flickr is:
# http://static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg
@photostream = $xpath->select_nodes(’/photos/photo’);
$totalphotos = @photostream;

for ($count=0; $count<$totalphotos; $count++)
{
$serverid = $photostream[$count]->{attributes}->{server};
$id = $photostream[$count]->{attributes}->{id};
$secret = $photostream[$count]->{attributes}->{secret};
$allphotos[$count]= “http://static.flickr.com/$serverid/”.$id.”_”.$secret.”_m.jpg”;
}

print < Content-type: text/html

onMouseOut="status=''">

END
[/code]

OK, so the next step would be to add another picture to the flickr account and see if that shows the new picture. As indeed it does. Although the new picture I was given to play with was something like 8×10 in size…sigh. Getting people to crop down pictures could be very interesting. I’ll add an arbitrary height/size to the img tag to keep that from fubaring the index page.

Pages: 1 2 3 4

del.icio.us:flickr slideshows  digg:flickr slideshows

1 Comment »

  1. Digital Ramble » Blog Archive » flickr api tip said,

    September 5, 2006 @ 12:49 pm

    […] In another quick and simple process, I personalized my About page a little with a bit of flickr html/java that they supply. Of course I’ve worked directly with their API, but in this case that’d be using a sledgehammer, since the good folks at flickr also provide a nice little javascript snippet to randomly select a couple of pictures/thumbnails to drop right in. I went to flickr’s badge generation page (logged in as moi, of course) to get started. […]

RSS feed for comments on this post · TrackBack URI

Leave a Comment

Bad Behavior has blocked 755 access attempts in the last 7 days.