1 | package Facebook::Graph::Publish::Checkin; |
---|
2 | BEGIN { |
---|
3 | $Facebook::Graph::Publish::Checkin::VERSION = '1.0300'; |
---|
4 | } |
---|
5 | |
---|
6 | use Any::Moose; |
---|
7 | extends 'Facebook::Graph::Publish'; |
---|
8 | |
---|
9 | use constant object_path => '/checkins'; |
---|
10 | |
---|
11 | has message => ( |
---|
12 | is => 'rw', |
---|
13 | predicate => 'has_message', |
---|
14 | ); |
---|
15 | |
---|
16 | sub set_message { |
---|
17 | my ($self, $message) = @_; |
---|
18 | $self->message($message); |
---|
19 | return $self; |
---|
20 | } |
---|
21 | |
---|
22 | has place => ( |
---|
23 | is => 'rw', |
---|
24 | predicate => 'has_place', |
---|
25 | ); |
---|
26 | |
---|
27 | sub set_place { |
---|
28 | my ($self, $value) = @_; |
---|
29 | $self->place($value); |
---|
30 | return $self; |
---|
31 | } |
---|
32 | |
---|
33 | has longitude => ( |
---|
34 | is => 'rw', |
---|
35 | isa => 'Num', |
---|
36 | predicate => 'has_longitude', |
---|
37 | ); |
---|
38 | |
---|
39 | sub set_longitude { |
---|
40 | my ($self, $value) = @_; |
---|
41 | $self->longitude($value); |
---|
42 | return $self; |
---|
43 | } |
---|
44 | |
---|
45 | has latitude => ( |
---|
46 | is => 'rw', |
---|
47 | isa => 'Num', |
---|
48 | predicate => 'has_latitude', |
---|
49 | ); |
---|
50 | |
---|
51 | sub set_latitude { |
---|
52 | my ($self, $value) = @_; |
---|
53 | $self->latitude($value); |
---|
54 | return $self; |
---|
55 | } |
---|
56 | |
---|
57 | has tags => ( |
---|
58 | is => 'rw', |
---|
59 | isa => 'ArrayRef', |
---|
60 | predicate => 'has_tags', |
---|
61 | lazy => 1, |
---|
62 | default => sub {[]}, |
---|
63 | ); |
---|
64 | |
---|
65 | sub set_tags { |
---|
66 | my ($self, $value) = @_; |
---|
67 | $self->tags($value); |
---|
68 | return $self; |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | around get_post_params => sub { |
---|
73 | my ($orig, $self) = @_; |
---|
74 | my $post = $orig->($self); |
---|
75 | if ($self->has_message) { |
---|
76 | push @$post, message => $self->message; |
---|
77 | } |
---|
78 | if ($self->has_place) { |
---|
79 | push @$post, place => $self->place; |
---|
80 | } |
---|
81 | if ($self->has_tags) { |
---|
82 | push @$post, tags => join(', ',@{$self->tags}); |
---|
83 | } |
---|
84 | if ($self->has_latitude && $self->has_longitude) { |
---|
85 | push @$post, coordinates => JSON->new->encode({ latitude => $self->latitude, longitude => $self->longitude }); |
---|
86 | } |
---|
87 | return $post; |
---|
88 | }; |
---|
89 | |
---|
90 | |
---|
91 | no Any::Moose; |
---|
92 | __PACKAGE__->meta->make_immutable; |
---|
93 | |
---|
94 | |
---|
95 | =head1 NAME |
---|
96 | |
---|
97 | Facebook::Graph::Publish::Checkin - Publish a location checkin. |
---|
98 | |
---|
99 | =head1 VERSION |
---|
100 | |
---|
101 | version 1.0300 |
---|
102 | |
---|
103 | =head1 SYNOPSIS |
---|
104 | |
---|
105 | my $fb = Facebook::Graph->new; |
---|
106 | |
---|
107 | $fb->add_checkin |
---|
108 | ->set_place(222047056390) |
---|
109 | ->publish; |
---|
110 | |
---|
111 | my $response = $fb->add_checkin |
---|
112 | ->set_place(222047056390) |
---|
113 | ->set_message('Mmm...pizza.') |
---|
114 | ->set_tags([qw(sarah.bownds 1647395831)]) |
---|
115 | ->set_latitude() |
---|
116 | ->set_longitude() |
---|
117 | ->publish; |
---|
118 | |
---|
119 | |
---|
120 | =head1 DESCRIPTION |
---|
121 | |
---|
122 | This module gives you quick and easy access to publish user checkins to locations. |
---|
123 | |
---|
124 | B<ATTENTION:> You must have the C<user_checkins> privilege to use this module, and C<friends_checkins> to get friends checkins. |
---|
125 | |
---|
126 | =head1 METHODS |
---|
127 | |
---|
128 | =head2 to ( id ) |
---|
129 | |
---|
130 | Specify a profile id to post to. Defaults to 'me', which is the currently logged in user. |
---|
131 | |
---|
132 | |
---|
133 | =head2 set_message ( message ) |
---|
134 | |
---|
135 | Sets the text to post to the wall. |
---|
136 | |
---|
137 | =head3 message |
---|
138 | |
---|
139 | A string of text. |
---|
140 | |
---|
141 | |
---|
142 | =head2 set_place ( id ) |
---|
143 | |
---|
144 | Sets the id of the place you are checking in to. |
---|
145 | |
---|
146 | =head3 id |
---|
147 | |
---|
148 | The id of a page for a place. For example C<222047056390> is the id of Pete's Pizza and Pub in Milwaukee, WI. |
---|
149 | |
---|
150 | |
---|
151 | =head2 set_latitude ( coord ) |
---|
152 | |
---|
153 | Sets sets the coords of your location. See also C<set_longitude> |
---|
154 | |
---|
155 | =head3 coord |
---|
156 | |
---|
157 | The decimal latitude of your current location. |
---|
158 | |
---|
159 | |
---|
160 | =head2 set_longitude ( coord ) |
---|
161 | |
---|
162 | Sets sets the coords of your location. See also C<set_latitude> |
---|
163 | |
---|
164 | =head3 coord |
---|
165 | |
---|
166 | The decimal longitude of your current location. |
---|
167 | |
---|
168 | |
---|
169 | =head2 set_tags ( list ) |
---|
170 | |
---|
171 | Sets the list of users at the location. |
---|
172 | |
---|
173 | =head3 list |
---|
174 | |
---|
175 | An array reference of Facebook user ids that are currently at this location with you. |
---|
176 | |
---|
177 | |
---|
178 | |
---|
179 | =head2 publish ( ) |
---|
180 | |
---|
181 | Posts the data and returns a L<Facebook::Graph::Response> object. The response object should contain the id: |
---|
182 | |
---|
183 | {"id":"1647395831_130068550371568"} |
---|
184 | |
---|
185 | =head1 LEGAL |
---|
186 | |
---|
187 | Facebook::Graph is Copyright 2010 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself. |
---|
188 | |
---|
189 | =cut |
---|