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

NAME

Flickr::Embed - Simple embedding of Flickr pictures into HTML

SYNOPSIS

 use Flickr::Embed;

 my $fe = Flickr::Embed::embed(
    tags=>'carrots',
    key=>'key',
    secret=>'secret',
 );

 my $blog = "$fe{html}This is a post which will appear on my blog.".
   "<br/><i>$fe{attribution}</i>";

DESCRIPTION

When you have an automated system to produce blog posts, sometimes you want to attach random pictures to it on some theme or other. For example, you might post the output of your unit tests every day and decide it would look good if each one had a different picture of a camel next to it. Flickr::Embed will look up your search terms on Flickr and return a given picture each time.

SYNOPSIS

embed()

Returns a hash of information taken from Flickr. In list context, returns everything it received from Flickr, subject to exclusions. In scalar context, returns just the first one, subject to exclusions. The return type is described in THE CONTENTS OF THE HASH, below. Takes a set of named parameters, described below.

PARAMETERS TO THE EMBED FUNCTION

key

A Flickr API key. See WHERE TO GET A KEY, below. Required.

secret

A Flickr API secret. See WHERE TO GET A KEY, below. Required.

tags

Tags to look for. Separate multiple tags with commas; only pictures which match all given tags will be returned. Required.

exclude

An arrayref of IDs of photos not to retrieve, presumably because you've seen them already.

per_page

How many photos to return (if this call is in list context). You will get at most this many; if any exclusions match, or if there aren't enough photos on Flickr with the given tags, you will get fewer.

THE CONTENTS OF THE HASH

html

A block of HTML ready to paste into a blog post.

attribution

An attribution of the author, including the licence. Most Creative Commons licences require attribution, and anyway it's good manners, so be sure to put this in somewhere.

Everything returned by flickr.photos.Search

for this photo, and and also

Everything returned by flickr.photos.getSizes

for the current size; see the Flickr API documentation.

WHERE TO GET A KEY

http://www.flickr.com/services/api/keys/apply/

If you don't have this, most of the tests will be skipped.

BUGS

If you exclude all the pictures in the first fetch, Flickr::Embed does not yet go back and get another batch; it behaves as if there were no pictures found. By default this will only happen if you have at least 100 exclusions. This will be fixed in a later release.

SEE ALSO

Flickr::API.

AUTHOR

Thomas Thurman, tthurman@gnome.org.

COPYRIGHT

This Perl module is copyright (C) Thomas Thurman, 2009. This is free software, and can be used/modified under the same terms as Perl itself.