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

NAME

Flickr::Photo - Represents a photo on Flickr.

VERSION

Version 0.02

SYNOPSIS

    use Flickr::Photo;

    my $photo = Flickr::Photo->new($flickr_api_key);

    if ($photo->id({id => 12345678}) {
      my $owner = $photo->owner;
      my $title = $photo->title;
    }

DESCRIPTION

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.

METHODS

new

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.

authenticate

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});

id

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.

server

Returns the server that stores the photo.

$server = $p->server;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

title

Returns the title of the photo.

$title = $p->title;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

rotation

Returns the rotation of the photo.

$rotation = $p->rotation;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

comments

Returns the number of comments that where made on the photo.

$comments = $p->comments;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

notes

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', }, ... ]

Always returns undef on error. Also on error the $p->{error} structure will be defined.

tags

Returns the tags pertaining to this photo.

$tags = $p->tags;

The return value is pointer to an array with the following structure:

[ { 'author' => '12345678@N00', 'id' => 123456, 'raw' => 'Wild Geese', 'value' => 'wildgeese', }, ... ]

Always returns undef on error. Also on error the $p->{error} structure will be defined.

is_favorite

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;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

license

Returns the type of license that the photo is under.

$license = $p->license;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

description

Returns the description of the photo.

$description = $p->description;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

secret

Returns the secret of the photo (if you have access to it).

$secret = $p->secret;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

is_family

Indicates wether this photo is visible to contacts marked as family.

$is_family = $p->is_family;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

is_friend

Indicates wether this photo is visible to contacts marked as friends.

$is_friend = $p->is_friend;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

is_public

Indicates wether this photo is public (visible to anyone).

$is_public= $p->is_public;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

perm_comment

Only exists if the currently authenticated user is the owner of the photo.

$perm_comment = $p->perm_comment;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

perm_add_meta

Only exists if the currently authenticated user is the owner of the photo.

$perm_add_meta = $p->perm_add_meta;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

can_comment

Indicates whether the user who is requesting the information can comment on this photo.

$can_comment = $p->can_comment;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

can_add_meta

Indicates whether the user who is requesting the information can add meta-information to this photo.

$can_add_meta= $p->can_add_meta;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

date_posted

Returns the date that this photo was posted on.

$date_posted = $p->date_posted;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

date_taken

Returns the date that this photo was taken on.

$date_taken = $p->date_taken;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

date_taken_granularity

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;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

owner

Returns a Flickr::Person object representing the owner of this photo.

$person = $p->owner;

Always returns undef on error. Also on error the $p->{error} structure will be defined.

exif

Returns the EXIF information associated with the photo (if there is any).

$exif = $p->exif;

The return value is pointer to an array with the following structure:

[ { 'tagspaceid' => '0', 'tag' => '271', 'tagspace' => 'EXIF', 'label' => 'Make', 'raw' => 'Canon' }, ... ]

Always returns undef on error. Also on error the $p->{error} structure will be defined.

sizes

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.

The return value is pointer to an array with the following structure:

[ { 'source' => 'http://photos5.flickr.com/7698342_d3473121ce_s.jpg', 'width' => '75', 'url' => 'http://www.flickr.com/photo_zoom.gne?id=7698342&amp;size=sq', 'label' => 'Square', 'height' => '75' }, ... ]

Always returns undef on error. Also on error the $p->{error} structure will be defined.

next_photo_info

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' }

Always returns undef on error. Also on error the $p->{error} structure will be defined.

prev_photo_info

Returns information on the previous photo in the photostream.

$prev_photo_info = $p->prev_photo_info;

The return value is pointer to a hash with the following structure:

{ 'secret' => 'df43eca33', 'title' => 'Cool previous photo!', 'url' => '/photos/janedoe/1234565/in/photostream/', 'id' => '1234565', 'thumb' => 'http://photos5.flickr.com/1234565_df43eca33_s.jpg' }

Always returns undef on error. Also on error the $p->{error} structure will be defined.

_reset_data

Internal method used for reseting the data on the currently instantiated photo.

_reset_error

Internal method used for reseting the error information on the last method call.

_setup_photos_api

Internal method used to setup the Flickr::API::Photos object.

_do_getInfo

Internal method used to parse the result from the Flickr::Photos::getInfo method and fill in our data with it's results.

_do_getExif

Internal method used to parse the result from the Flickr::Photos::getExif method and fill in our data with it's results.

_do_getSizes

Internal method used to parse the result from the Flickr::Photos::getSizes method and fill in our data with it's results.

_do_getContext

Internal method used to parse the result from the Flickr::Photos::getContext method and fill in our data with it's results.

AUTHOR

Nuno Nunes, <nfmnunes@cpan.org>

COPYRIGHT & LICENSE

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.

SEE ALSO

<http://www.flickr.com/>, Flickr::Person, Flickr::Photoset