source: perl/modules/Facebook/lib/Facebook/Graph/Picture.pm @ cfca761

Last change on this file since cfca761 was cfca761, checked in by Edward Z. Yang <ezyang@mit.edu>, 13 years ago
Add vanilla Facebook::Graph. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
  • Property mode set to 100644
File size: 2.5 KB
Line 
1package Facebook::Graph::Picture;
2BEGIN {
3  $Facebook::Graph::Picture::VERSION = '1.0300';
4}
5
6use Any::Moose;
7with 'Facebook::Graph::Role::Uri';
8
9has type => (
10    is          => 'rw',
11    predicate   => 'has_type',
12);
13
14has object_name => (
15    is          => 'rw',
16    default     => '',
17);
18
19sub get_small {
20    my ($self) = @_;
21    $self->type('small');
22    return $self;
23}
24
25sub get_square {
26    my ($self) = @_;
27    $self->type('square');
28    return $self;
29}
30
31sub get_large {
32    my ($self) = @_;
33    $self->type('large');
34    return $self;
35}
36
37sub 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
50no Any::Moose;
51__PACKAGE__->meta->make_immutable;
52
53
54=head1 NAME
55
56Facebook::Graph::Picture - Get the URI for the picture of any object.
57
58=head1 VERSION
59
60version 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
73This 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
80Get a large picture. 200 pixels wide by a variable height.
81
82=head3 id
83
84The unique id or object name of an object.
85
86B<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
91Get a small picture. 50 pixels wide by a variable height.
92
93=head3 id
94
95The unique id or object name of an object.
96
97B<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
102Get a square picture. 50 pixels wide by 50 pixels tall.
103
104=head3 id
105
106The unique id or object name of an object.
107
108B<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
115Returns 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
120Facebook::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
Note: See TracBrowser for help on using the repository browser.