Flickr-Embed
view release on metacpan or search on metacpan
lib/Flickr/Embed.pm view on Meta::CPAN
$url =~ s!sizes/./!!;
$result{html} = "<a title=\"$title by $author, on Flickr\" ".
"href=\"$result{source}\">" .
"<img src=\"$url\" alt=\"$title\" ".
"width=\"$result{width}\" height=\"$result{height}\" align=\"right\" /></a>";
$result{attribution} = "Copyright © $author. ".
$licence_names->{$result{license}};
push @result, \%result;
last unless wantarray;
}
# later, if result==(), and we've excluded any, go round and get the next ones
return $result[0] unless wantarray;
return @result;
}
1;
=head1 NAME
Flickr::Embed - Simple embedding of Flickr pictures into HTML
=head1 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>";
=head1 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.
C<Flickr::Embed> will look up your search terms on Flickr and return a
given picture each time.
=head1 SYNOPSIS
=head2 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.
=head1 PARAMETERS TO THE EMBED FUNCTION
=head2 key
A Flickr API key. See WHERE TO GET A KEY, below. Required.
=head2 secret
A Flickr API secret. See WHERE TO GET A KEY, below. Required.
=head2 tags
Tags to look for. Separate multiple tags with commas; only pictures which
match all given tags will be returned. Required.
=head2 exclude
An arrayref of IDs of photos not to retrieve, presumably because you've seen them
already.
=head2 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.
=head1 THE CONTENTS OF THE HASH
=head2 html
A block of HTML ready to paste into a blog post.
=head2 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.
=head2 Everything returned by flickr.photos.Search
for this photo, and and also
=head2 Everything returned by flickr.photos.getSizes
for the current size; see the Flickr API documentation.
=head1 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.
=head1 BUGS
If you exclude all the pictures in the first fetch, C<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.
=head1 SEE ALSO
( run in 1.194 second using v1.01-cache-2.11-cpan-71847e10f99 )