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