1package Facebook::Graph::Picture; 2$Facebook::Graph::Picture::VERSION = '1.0801'; 3use Any::Moose; 4with 'Facebook::Graph::Role::Uri'; 5 6has type => ( 7 is => 'rw', 8 predicate => 'has_type', 9); 10 11has object_name => ( 12 is => 'rw', 13 default => '', 14); 15 16sub get_small { 17 my ($self) = @_; 18 $self->type('small'); 19 return $self; 20} 21 22sub get_square { 23 my ($self) = @_; 24 $self->type('square'); 25 return $self; 26} 27 28sub get_large { 29 my ($self) = @_; 30 $self->type('large'); 31 return $self; 32} 33 34sub uri_as_string { 35 my ($self) = @_; 36 my %query; 37 if ($self->has_type) { 38 $query{type} = $self->type; 39 } 40 my $uri = $self->uri; 41 $uri->path($self->object_name . '/picture'); 42 $uri->query_form(%query); 43 return $uri->as_string; 44} 45 46 47no Any::Moose; 48__PACKAGE__->meta->make_immutable; 49 50 51=head1 NAME 52 53Facebook::Graph::Picture - Get the URI for the picture of any object. 54 55=head1 VERSION 56 57version 1.0801 58 59=head1 SYNOPSIS 60 61 my $fb = Facebook::Graph->new; 62 63 my $default_picture = $fb->picture('16665510298')->uri_as_string; 64 my $large_picture = $fb->picture('16665510298')->get_large->uri_as_string; 65 my $small_picture = $fb->picture('16665510298')->get_small->uri_as_string; 66 my $square_picture = $fb->picture('16665510298')->get_square->uri_as_string; 67 68=head1 DESCRIPTION 69 70This module allows you to generate the URL needed to fetch a picture for any object on Facebook. 71 72=head1 METHODS 73 74 75=head2 get_large ( id ) 76 77Get a large picture. 200 pixels wide by a variable height. 78 79=head3 id 80 81The unique id or object name of an object. 82 83B<Example:> For user "Sarah Bownds" you could use either her profile id C<sarahbownds> or her object id C<767598108>. 84 85 86=head2 get_small ( id ) 87 88Get a small picture. 50 pixels wide by a variable height. 89 90=head3 id 91 92The unique id or object name of an object. 93 94B<Example:> For user "Sarah Bownds" you could use either her profile id C<sarahbownds> or her object id C<767598108>. 95 96 97=head2 get_square ( id ) 98 99Get a square picture. 50 pixels wide by 50 pixels tall. 100 101=head3 id 102 103The unique id or object name of an object. 104 105B<Example:> For user "Sarah Bownds" you could use either her profile id C<sarahbownds> or her object id C<767598108>. 106 107 108 109 110=head2 uri_as_string () 111 112Returns a URI string based upon all the methods you've called so far on the query. You can throw the resulting URI right into an <img> tag. 113 114 115=head1 LEGAL 116 117Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself. 118 119=cut 120