The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

OpenInteract2::Action::FlickrFeed - OpenInteract2 action to retrieve a Flickr feed and display it through a template

SYNOPSIS

First, you need to register your type; in your website's conf/server.ini:

 [action_types]
 ...
 flickr = OpenInteract2::Action::FlickrFeed

Next, reference the action type in your package's conf/action.ini:

 [my_flickr]
 type         = flickr
 title        = My Flickr Photos
 feed_id      = 62037332@N99
 template     = myapp::flickr_feed
 cache_expire = 30m

Now you can deposit the results of your feed married to your 'myapp::flickr_feed' template:

 [% OI.action_execute( 'my_flickr' ) %]

You can also add it as a box:

 [% OI.box_add( 'my_flickr' ) %]

DESCRIPTION

This is a simple extension of OpenInteract2::Action::RSS which grabs interesting data out of the Atom/RSS Flickr feed and makes them available to your template. So in addition to the 'feed' variable you also have access to an array 'photos' which contains a number of hashrefs with the following keys:

  • link: URL to the full page of this photo

  • title: Title of this photo

  • img_src: URL to small photo

  • width: Image width (pixels)

  • height: Image height (pixels)

So you can do something like this in your template:

 Recent photos:<br /> 
 [% FOREACH photo = photos %]
   <a href="[% photo.link %]"
      title="[% photo.title %]"><img src="[% photo.img_src %]"
                                     width="[% photo.width %]"
                                     height="[% photo.height %]" /></a> <br />
 [% END %]

Properties

To make this happen you can define the following properties in your action:

feed_id (required)

This is the ID of your feed. To find it just browse to your Flickr home page and find the 'RSS 2.0' or 'Atom' links toward the bottom. They'll look something like this:

 http://www.flickr.com/services/feeds/photos_public.gne?id=62037332@N00&format=atom_03

The value following the id parameter is what you want; in this case it's '62037332@N00'.

template (optional; default is defined in OpenInteract2::Action::RSS)

Specify the template used to display your photos.

feed_format (optional; default 'atom_03')

Define the 'format' to be passed in the URL. By default this is 'atom_03' and you'll probably never need to change it. (If you have philosophical objections to Atom you can use 'rss_200'.)

cache_expire (optional but strongly recommended)

Same as OpenInteract2::Action::RSS

num_photos (optional; default 0, which means display all)

Number of photos to display; by default we show all of them. You can also control this from your template if you wish.

SEE ALSO

OpenInteract2::Action::RSS

XML::Feed

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Chris Winters

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters, <chris@cwinters.com>