Flickr::Photo - Represents a photo on Flickr.
Version 0.02
use Flickr::Photo; my $photo = Flickr::Photo->new($flickr_api_key); if ($photo->id({id => 12345678}) { my $owner = $photo->owner; my $title = $photo->title; }
This class represents a photo on Flickr. It uses the Flickr::API::Photos class (and other's it finds necessary) in order to retrieve and send information to/from Flickr regarding a single photo.
The class tries to be well behaved and Flickr-server-friendly by using lazy data fetching and caching techniques.
The methods that are available are read/write when the item is alterable via the Flickr API. What that means is that if you call a method with an argument it will set that value while if you call it without any arguments it will give you the current value.
Nevertheless do read on the descriptions of each method for more information on it's usage.
IMPORTANT NOTE: So far the above statement about the methods being read/write is wishfull thinking as I've only implemented the read funcionality. Write is coming soon.
Sets up the structure for usage.
$photo = Flickr::Photo->new({ api_key => $my_flickr_api_key, email => $my_flickr_email, password => $my_flickr_password});
The 'my_flickr_email' and 'my_flickr_password' are optional. See the method 'authenticate' for further explanation.
Some interactions with flickr do require an authenticated user and some information is only accessible in this way and for those calls to be successfull you must provide these parameters. For everything else you really don't need them.
This method provides a way for the user to authenticate on all future calls.
This authentication data may also be provided via the new method.
$person->authenticate({ email => $my_flickr_email, password => $my_flickr_password});
This method has two distinct behaviours depending on whether you call it with or without a parameter.
If you call it without any params it just gives you back the ID of the photo it is currently representing (assuming there is one photo being represented at this time).
$id = $p->id;
On the other hand, if you call it with a parameter it assumes you wish to represent the photo whose ID you just passed in and resets itself accordingly, deleting any data it might have had from a previous photo, and gets the basic information on the photo you requested.
$ok = $p->id($photo_id);
Always returns undef on error. Also on error the $p->{error} structure will be defined.
Returns the server that stores the photo.
$server = $p->server;
Returns the title of the photo.
$title = $p->title;
Returns the rotation of the photo.
$rotation = $p->rotation;
Returns the number of comments that where made on the photo.
$comments = $p->comments;
Returns the notes pertaining to this photo.
$notes = $p->notes;
The return value is pointer to an array with the following structure:
[ { 'h' => 50, 'w' => 100, 'x' => 10, 'y' => 10, 'authorname' => 'Some One', 'author' => '12345678@N00', 'value' => 'Some interesting remark', }, ... ]
Returns the tags pertaining to this photo.
$tags = $p->tags;
[ { 'author' => '12345678@N00', 'id' => 123456, 'raw' => 'Wild Geese', 'value' => 'wildgeese', }, ... ]
If you are using authentication (see 'new') it indicates wether you count this photo as a favorite of yours. If you are not authenticated this method doesn't realy make sense and always returns 0.
$is_favorite = $p->is_favorite;
Returns the type of license that the photo is under.
$license = $p->license;
Returns the description of the photo.
$description = $p->description;
Returns the secret of the photo (if you have access to it).
$secret = $p->secret;
Indicates wether this photo is visible to contacts marked as family.
$is_family = $p->is_family;
Indicates wether this photo is visible to contacts marked as friends.
$is_friend = $p->is_friend;
Indicates wether this photo is public (visible to anyone).
$is_public= $p->is_public;
Only exists if the currently authenticated user is the owner of the photo.
$perm_comment = $p->perm_comment;
$perm_add_meta = $p->perm_add_meta;
Indicates whether the user who is requesting the information can comment on this photo.
$can_comment = $p->can_comment;
Indicates whether the user who is requesting the information can add meta-information to this photo.
$can_add_meta= $p->can_add_meta;
Returns the date that this photo was posted on.
$date_posted = $p->date_posted;
Returns the date that this photo was taken on.
$date_taken = $p->date_taken;
Returns the granularity of the dateken information. According to the documentation (<http://www.flickr.com/services/api/misc.dates.html>) this value may have three different meanings (at the time of this writing at least): 0: 'Y-m-d H:i:s' 4: 'Y-m' 6: 'Y'
$date_taken_granularity = $p->date_taken_granularity;
Returns a Flickr::Person object representing the owner of this photo.
$person = $p->owner;
Returns the EXIF information associated with the photo (if there is any).
$exif = $p->exif;
[ { 'tagspaceid' => '0', 'tag' => '271', 'tagspace' => 'EXIF', 'label' => 'Make', 'raw' => 'Canon' }, ... ]
Returns information on the various available sizes of the photo.
$sizes = $p->sizes;
At the time of this writing existing sizes are: - Square; - Thumbnail; - Small; - Medium; - Original.
[ { 'source' => 'http://photos5.flickr.com/7698342_d3473121ce_s.jpg', 'width' => '75', 'url' => 'http://www.flickr.com/photo_zoom.gne?id=7698342&size=sq', 'label' => 'Square', 'height' => '75' }, ... ]
Returns information on the next photo in the photostream.
$next_photo_info = $p->next_photo_info;
The return value is pointer to a hash with the following structure:
{ 'secret' => 'df435fa33', 'title' => 'Great next photo!', 'url' => '/photos/janedoe/1234567/in/photostream/', 'id' => '1234567', 'thumb' => 'http://photos5.flickr.com/1234567_df435fa33_s.jpg' }
Returns information on the previous photo in the photostream.
$prev_photo_info = $p->prev_photo_info;
{ 'secret' => 'df43eca33', 'title' => 'Cool previous photo!', 'url' => '/photos/janedoe/1234565/in/photostream/', 'id' => '1234565', 'thumb' => 'http://photos5.flickr.com/1234565_df43eca33_s.jpg' }
Internal method used for reseting the data on the currently instantiated photo.
Internal method used for reseting the error information on the last method call.
Internal method used to setup the Flickr::API::Photos object.
Internal method used to parse the result from the Flickr::Photos::getInfo method and fill in our data with it's results.
Internal method used to parse the result from the Flickr::Photos::getExif method and fill in our data with it's results.
Internal method used to parse the result from the Flickr::Photos::getSizes method and fill in our data with it's results.
Internal method used to parse the result from the Flickr::Photos::getContext method and fill in our data with it's results.
Nuno Nunes, <nfmnunes@cpan.org>
<nfmnunes@cpan.org>
Copyright 2005 Nuno Nunes, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
<http://www.flickr.com/>, Flickr::Person, Flickr::Photoset
To install Flickr::Photo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Flickr::Photo
CPAN shell
perl -MCPAN -e shell install Flickr::Photo
For more information on module installation, please visit the detailed CPAN module installation guide.