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