Graph.pm

filter: Statementstmt 49.1% 85 / 173 Branchbran 7.1% 4 / 56 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 61.5% 24 / 39 Podpod 100% 19 / 19 totaltotal 44.4% 132 / 297 CC 31 SCAR 23.2
CC
31
Cov
38%
add_page_tab
30.0
request_extended_access_token
20.0
add_post
20.0
CRAP 10.2
« Graph/BatchRequests.pm ↑ Summary Graph/Response.pm »
1 package Facebook::Graph;
2 4 $Facebook::Graph::VERSION = '1.1205';
3 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use MIME::Base64::URLSafe;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Facebook::Graph::AccessToken;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Facebook::Graph::Authorize;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Facebook::Graph::Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Facebook::Graph::Picture;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Facebook::Graph::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Facebook::Graph::Publish::Post;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Facebook::Graph::Publish::Photo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Facebook::Graph::Publish::Checkin;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use Facebook::Graph::Publish::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use Facebook::Graph::Publish::RSVPMaybe;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Facebook::Graph::Publish::RSVPAttending;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use Facebook::Graph::Publish::RSVPDeclined;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Facebook::Graph::Publish::PageTab;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use Facebook::Graph::BatchRequests;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use Facebook::Graph::Page::Feed;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use Ouch;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 4 has app_id => (
25 is => 'ro',
26 );
27  
28 4 has secret => (
29 is => 'ro',
30 predicate => 'has_secret',
31 );
32  
33 4 has postback => (
34 is => 'rw',
35 );
36  
37 4 has access_token => (
38 is => 'rw',
39 predicate => 'has_access_token',
40 );
41  
42 1 ▶sub parse_signed_request {
Subroutine parse_signed_request: called CC=3 SCAR=11.5
Pod documented
43 1 my ($self, $signed_request) = @_;
44 1 require Digest::SHA;
45 1 my ($encoded_sig, $payload) = split(/\./, $signed_request);
46  
47 1 my $sig = urlsafe_b64decode($encoded_sig);
48 1 my $data = JSON->new->decode(urlsafe_b64decode($payload));
49  
50 1 ▶ if (uc($data->{'algorithm'}) ne "HMAC-SHA256") {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $data->{"algorithm"} ne "HMAC-SHA256") 0 1 1
51 0 ouch '500', 'Unknown algorithm. Expected HMAC-SHA256';
52 }
53  
54 1 my $expected_sig = Digest::SHA::hmac_sha256($payload, $self->secret);
55 1 ▶ if ($sig ne $expected_sig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig ne $expected_sig) 0 1 1
56 0 ouch '500', 'Bad Signed JSON signature!';
57 }
58 1 return $data;
59 }
60  
61 2 ▶sub request_access_token {
Subroutine request_access_token: called CC=1 SCAR=0.0
Pod documented
62 2 my ($self, $code) = @_;
63 2 my $token = Facebook::Graph::AccessToken->new(
64 code => $code,
65 postback => $self->postback,
66 secret => $self->secret,
67 app_id => $self->app_id,
68 )->request;
69 2 $self->access_token($token->token);
70 2 return $token;
71 }
72  
73 0 ▶sub request_extended_access_token {
Subroutine request_extended_access_token: not called CC=4 SCAR=30.0
Pod documented
74 0 my ($self, $access_token) = @_;
75  
76 0 ▶ die "request_extended_access_token requires an access_token" unless $access_token or $self->has_access_token;
Branch: 1 branch
BranchTrueFalseTotal
unless $access_token or $self->has_access_token 0 0 0
Condition0%0/3
$access_token or $self->has_access_token
l!l&&r!l&&!r
000
MC/DC0%0/2
$access_token or $self->has_access_token
$access_token $self->has_access_token
Truth table0%0/3
A or B
A= $access_tokenB= $self->has_access_token
ABresult
1X1
011
000
77 0 ▶ $access_token = $access_token ? $access_token : $self->access_token;
Branch: 1 branch
BranchTrueFalseTotal
$access_token ? : 0 0 0
78  
79 0 my $token = Facebook::Graph::AccessToken->new(
80 access_token => $access_token,
81 postback => $self->postback,
82 secret => $self->secret,
83 app_id => $self->app_id,
84 )->request;
85 0 $self->access_token($token->token);
86 0 return $token;
87 }
88  
89 0 ▶sub convert_sessions {
Subroutine convert_sessions: not called CC=1 SCAR=6.9
Pod documented
90 0 my ($self, $sessions) = @_;
91 0 return Facebook::Graph::Session->new(
92 secret => $self->secret,
93 app_id => $self->app_id,
94 sessions => $sessions,
95 )
96 ->request
97 ->as_hashref;
98 }
99  
100 0 ▶sub authorize {
Subroutine authorize: not called CC=1 SCAR=6.9
Pod documented
101 0 my ($self) = @_;
102 0 return Facebook::Graph::Authorize->new(
103 app_id => $self->app_id,
104 postback => $self->postback,
105 );
106 }
107  
108 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
Pod documented
109 0 my ($self, $object_name, %params) = @_;
110 0 return $self->query->find($object_name, %params)->request->as_hashref;
111 }
112  
113 0 ▶sub request {
Subroutine request: not called CC=1 SCAR=6.9
Pod documented
114 0 my ($self, $uri) = @_;
115 0 return Facebook::Graph::Request->new->get($uri);
116 }
117  
118 1 ▶sub query {
Subroutine query: called CC=3 SCAR=12.7
Pod documented
119 1 my ($self, %params) = @_;
120 1 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 1 1
121 0 $params{access_token} = $self->access_token;
122 }
123 1 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 1 1
124 0 $params{secret} = $self->secret;
125 }
126 1 return Facebook::Graph::Query->new(%params);
127 }
128  
129 0 ▶sub batch_requests {
Subroutine batch_requests: not called CC=1 SCAR=6.9
Pod documented
130 0 my ($self, %params) = @_;
131 0 $params{access_token} = $self->access_token;
132 0 return Facebook::Graph::BatchRequests->new(%params);
133 }
134  
135 1 ▶sub picture {
Subroutine picture: called CC=1 SCAR=0.0
Pod documented
136 1 my ($self, $object_name, %params) = @_;
137 1 $params{object_name} = $object_name;
138 1 return Facebook::Graph::Picture->new( %params );
139 }
140  
141 0 ▶sub add_post {
Subroutine add_post: not called CC=4 SCAR=30.0
Pod documented
142 0 my ($self, $object_name, %params) = @_;
143 0 ▶ if ($object_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object_name) 0 0 0
144 0 $params{object_name} = $object_name;
145 }
146 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
147 0 $params{access_token} = $self->access_token;
148 }
149 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
150 0 $params{secret} = $self->secret;
151 }
152 0 return Facebook::Graph::Publish::Post->new( %params );
153 }
154  
155  
156 0 ▶sub add_page_feed {
Subroutine add_page_feed: not called CC=3 SCAR=24.8
Pod documented
157 0 my ($self, %params) = @_;
158 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
159 0 $params{access_token} = $self->access_token;
160 }
161 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
162 0 $params{secret} = $self->secret;
163 }
164 0 return Facebook::Graph::Page::Feed->new( %params );
165 };
166  
167  
168 0 ▶sub add_photo {
Subroutine add_photo: not called CC=4 SCAR=30.0
Pod documented
169 0 my ($self, $object_name, %params) = @_;
170 0 ▶ if ($object_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object_name) 0 0 0
171 0 $params{object_name} = $object_name;
172 }
173 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
174 0 $params{access_token} = $self->access_token;
175 }
176 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
177 0 $params{secret} = $self->secret;
178 }
179 0 return Facebook::Graph::Publish::Photo->new( %params );
180 }
181  
182 0 ▶sub add_checkin {
Subroutine add_checkin: not called CC=4 SCAR=30.0
Pod documented
183 0 my ($self, $object_name, %params) = @_;
184 0 ▶ if ($object_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object_name) 0 0 0
185 0 $params{object_name} = $object_name;
186 }
187 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
188 0 $params{access_token} = $self->access_token;
189 }
190 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
191 0 $params{secret} = $self->secret;
192 }
193 0 return Facebook::Graph::Publish::Checkin->new( %params );
194 }
195  
196 0 ▶sub add_comment {
Subroutine add_comment: not called CC=3 SCAR=24.8
Pod documented
197 0 my ($self, $object_name, %params) = @_;
198 0 $params{object_name} = $object_name;
199 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
200 0 $params{access_token} = $self->access_token;
201 }
202 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
203 0 $params{secret} = $self->secret;
204 }
205 0 return Facebook::Graph::Publish::Comment->new( %params );
206 }
207  
208 0 ▶sub add_page_tab {
Subroutine add_page_tab: not called CC=5 SCAR=34.0
Pod documented
209 0 my ($self, $object_name, $app_id, %params) = @_;
210  
211 0 ▶ die "page_id and app_id are required" unless $object_name and $app_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $object_name and $app_id 0 0 0
Condition0%0/3
$object_name and $app_id
!ll&&!rl&&r
000
MC/DC0%0/2
$object_name and $app_id
$object_name $app_id
Truth table0%0/3
A and B
A= $object_nameB= $app_id
ABresult
0X0
100
111
212  
213 0 $params{object_name} = $object_name;
214  
215 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
216 0 $params{access_token} = $self->access_token;
217 }
218  
219 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
220 0 $params{secret} = $self->secret;
221 }
222  
223 0 $params{app_id} = $app_id;
224  
225 0 return Facebook::Graph::Publish::PageTab->new( %params );
226 }
227  
228  
229  
230 0 ▶sub rsvp_maybe {
Subroutine rsvp_maybe: not called CC=3 SCAR=24.8
Pod documented
231 0 my ($self, $object_name, %params) = @_;
232 0 $params{object_name} = $object_name;
233 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
234 0 $params{access_token} = $self->access_token;
235 }
236 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
237 0 $params{secret} = $self->secret;
238 }
239 0 return Facebook::Graph::Publish::RSVPMaybe->new( %params );
240 }
241  
242 0 ▶sub rsvp_attending {
Subroutine rsvp_attending: not called CC=3 SCAR=24.8
Pod documented
243 0 my ($self, $object_name, %params) = @_;
244 0 $params{object_name} = $object_name;
245 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
246 0 $params{access_token} = $self->access_token;
247 }
248 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
249 0 $params{secret} = $self->secret;
250 }
251 0 return Facebook::Graph::Publish::RSVPAttending->new( %params );
252 }
253  
254 0 ▶sub rsvp_declined {
Subroutine rsvp_declined: not called CC=3 SCAR=24.8
Pod documented
255 0 my ($self, $object_name, %params) = @_;
256 0 $params{object_name} = $object_name;
257 0 ▶ if ($self->has_access_token) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_access_token) 0 0 0
258 0 $params{access_token} = $self->access_token;
259 }
260 0 ▶ if ($self->has_secret) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_secret) 0 0 0
261 0 $params{secret} = $self->secret;
262 }
263 0 return Facebook::Graph::Publish::RSVPDeclined->new( %params );
264 }
265  
266  
267 4 1;
268  
269 =head1 NAME
270  
271 Facebook::Graph - A fast and easy way to integrate your apps with Facebook.
272  
273 =head1 VERSION
274  
275 version 1.1205
276  
277 =head1 NOTICE OF DEPRECATION
278  
279 Facebook::Graph brought the world of Facebook to Perl, but as Facebook is massively changing their APIs it is impossible to keep up with a heavy weight module like Facebook::Graph. Instead, we recommend switching to the lighter weight L<Facebook::OpenGraph> module. We won't be removing Facebook::Graph from CPAN, but we won't be adding new features to keep up with all of Facebook's constant changes either.
280  
281 =head1 SYNOPSIS
282  
283 my $fb = Facebook::Graph->new;
284 $fb->access_token($token);
285 my $sarah_bownds = $fb->fetch('767598108');
286 my $perl_page = $fb->fetch('16665510298');
287  
288 Or better yet:
289  
290 my $sarah_bownds = $fb->query
291 ->find('767598108')
292 ->include_metadata
293 ->select_fields(qw( id name picture ))
294 ->request
295 ->as_hashref;
296  
297 my $sarahs_picture_uri = $fb->picture('sarahbownds')->get_large->uri_as_string;
298  
299 You can also do asynchronous calls like this:
300  
301 my $sarah = $fb->query->find('767598108'); # making request in background here
302 # ... do stuff here ...
303 my $hashref = $sarah->as_hashref; # handling the response here
304  
305  
306 Or fetching a response from a URI you already have:
307  
308 my $hashref = $fb->request('https://graph.facebook.com/16665510298')->as_hashref;
309  
310  
311 =head2 Building A Privileged App
312  
313 my $fb = Facebook::Graph->new(
314 app_id => $facebook_application_id,
315 secret => $facebook_application_secret,
316 postback => 'https://www.yourapplication.com/facebook/oauth/postback',
317 );
318  
319 Get the user to authorize your app (only needed if you want to fetch non-public information or publish stuff):
320  
321 my $uri = $fb
322 ->authorize
323 ->extend_permissions(qw(offline_access publish_stream))
324 ->uri_as_string;
325  
326 # redirect the user's browser to $uri
327  
328 Handle the Facebook authorization code postback:
329  
330 my $q = Plack::Request->new($env);
331 $fb->request_access_token($q->query_param('code'));
332  
333 #now retrieve extended access token
334 $fb->request_extended_access_token; #extended access token now in $fb->access_token
335  
336 Or if you already had the access token:
337  
338 $fb->access_token($token);
339 $fb->request_extended_access_token;
340  
341 Or simply:
342  
343 $fb->request_extended_access_token($token);
344  
345 Get some info:
346  
347 my $user = $fb->fetch('me');
348 my $friends = $fb->fetch('me/friends');
349 my $perl_page = $fb->fetch('16665510298');
350  
351 Use a different version of the API:
352  
353 my $user = $fb->fetch('me', api_version => 'v2.5');
354  
355 =head1 DESCRIPTION
356  
357 This is a Perl interface to the Facebook Graph API L<http://developers.facebook.com/docs/api>. With this module you can currently query public Facebook data, query privileged Facebook data, and build a privileged Facebook application. See the TODO for all that this module cannot yet do.
358  
359 For example code, see L<Facebook::Graph::Cookbook>.
360  
361 B<WARNING:> The work on this module has only just begun because the Graph API itself isn't very new, and I'm only working on it as I have some tuits. Therefore things are potentially subject to change drastically with each release.
362  
363  
364 =head1 METHODS
365  
366 =head2 new ( [ params ] )
367  
368 The constructor.
369  
370 =head3 params
371  
372 A hash of base parameters, just so you don't have to pass them around. If you only want to do public queries then these params are not needed.
373  
374 =over
375  
376 =item access_token
377  
378 An access token string used to make Facebook requests as a privileged user. Required if you want to make privileged queries or perform privileged actions on Facebook objects.
379  
380 =item app_id
381  
382 The application id that you get from Facebook after registering (L<http://developers.facebook.com/setup/>) your application on their site. Required if you'll be calling the C<request_access_token>, C<convert_sessions>, or C<authorize> methods.
383  
384 =item secret
385  
386 The application secret that you get from Facebook after registering your application. Required if you'll be calling the C<request_access_token> or C<convert_sessions> methods.
387  
388 =item postback
389  
390 The URI that Facebook should post your authorization code back to. Required if you'll be calling the C<request_access_token> or C<authorize> methods.
391  
392 B<NOTE:> It must be a sub URI of the URI that you put in the Application Settings > Connect > Connect URL field of your application's profile on Facebook.
393  
394 =back
395  
396  
397 =head2 authorize ( )
398  
399 Creates a L<Facebook::Graph::Authorize> object, which can be used to get permissions from a user for your application.
400  
401  
402 =head2 request_access_token ( code )
403  
404 Creates a L<Facebook::Graph::AccessToken> object and fetches an access token from Facebook, which will allow everything you do with Facebook::Graph to work within user privileges rather than through the public interface. Returns a L<Facebook::Graph::AccessToken::Response> object, and also sets the C<access_token> property in the Facebook::Graph object.
405  
406 =head2 request_extended_access_token ( access_token )
407  
408 Note: access_token is optional. Creates a L<Facebook::Graph::AccessToken> object and fetches an (https://developers.facebook.com/docs/facebook-login/access-tokens/#extending) extended access token from Facebook.
409 This method accepts an optional access token. If you have called C<request_access_token> already on the Facebook::Graph object and C<access_token> is set, then you do not have to pass
410 in an access token. However, if you have an access token stored from a previous object, you will need to pass it in.
411  
412 =head3 code
413  
414 An authorization code string that you should have gotten by going through the C<authorize> process.
415  
416  
417 =head2 query ( )
418  
419 Creates a L<Facebook::Graph::Query> object, which can be used to fetch and search data from Facebook.
420  
421 =head2 batch_requests ( uri )
422  
423 Creates a L<Facebook::Graph::BatchRequests> object, which can be used to send multiple requests in a single HTTP request.
424  
425 =head2 request ( uri )
426  
427 Fetch a Facebook::Graph URI you already have.
428  
429 =head3 uri
430  
431 The URI to fetch. For example: https://graph.facebook.com/amazon
432  
433 =head2 fetch ( id )
434  
435 Returns a hash reference of an object from facebook. A quick way to grab an object from Facebook. These two statements are identical:
436  
437 my $sarah = $fb->fetch('767598108');
438  
439 my $sarah = $fb->query->find('767598108')->request->as_hashref;
440  
441 =head3 id
442  
443 An object id like C<16665510298> for the Perl page.
444  
445 =head2 picture ( id )
446  
447 Returns a L<Facebook::Graph::Picture> object, which can be used to generate the URLs of the pictures of any object on Facebook.
448  
449 =head3 id
450  
451 An object id like C<16665510298> for the Perl page.
452  
453  
454  
455 =head2 add_post ( [ id ] )
456  
457 Creates a L<Facebook::Graph::Publish::Post> object, which can be used to publish data to a user's feed/wall.
458  
459 =head2 add_page_feed ( )
460  
461 Creates a L<Facebook::Graph::Page::Feed> object, which can be used to add a post to a Facebook page.
462  
463 =head2 add_photo ( [ id ] )
464  
465 Creates a L<Facebook::Graph::Publish::Photo> object, which can be used to publish a photo to a user's feed/wall.
466  
467 =head3 id
468  
469 Optionally provide an object id to place it on. Requires that you have administrative access to that page/object.
470  
471  
472 =head2 add_checkin ( [ id ] )
473  
474 Creates a L<Facebook::Graph::Publish::Checkin> object, which can be used to publish a checkin to a location.
475  
476 =head3 id
477  
478 Optionally provide an user id to check in. Requires that you have administrative access to that user.
479  
480  
481 =head2 add_comment ( id )
482  
483 Creates a L<Facebook::Graph::Publish::Comment> object that you can use to comment on a note.
484  
485 =head3 id
486  
487 The id of the post you want to comment on.
488  
489  
490 =head2 add_page_tab ( page_id, app_id )
491  
492 Creates a L<Facebook::Graph::Publish::PageTab> object, which can be used to publish an app as a page tab.
493  
494 =head3 id
495  
496 Optionally provide an object id to place it on. Requires that you have administrative access to that page/object.
497  
498  
499  
500 =head2 rsvp_maybe ( id )
501  
502 RSVP as 'maybe' to an event.
503  
504 =head3 id
505  
506 The id of an event.
507  
508 =head2 rsvp_attending ( id )
509  
510 RSVP as 'attending' to an event.
511  
512 =head3 id
513  
514 The id of an event.
515  
516 =head2 rsvp_declined ( id )
517  
518 RSVP as 'declined' to an event.
519  
520 =head3 id
521  
522 The id of an event.
523  
524  
525  
526 =head2 convert_sessions ( sessions )
527  
528 A utility method to convert old sessions into access tokens that can be used with the Graph API. Returns an array reference of hash references of access tokens.
529  
530 [
531 {
532 "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
533 "expires": 1271649600,
534 },
535 ...
536 ]
537  
538 See also L<Facebook::Graph::Session>.
539  
540 =head3 sessions
541  
542 An array reference of session ids from the old Facebook API.
543  
544  
545 =head2 parse_signed_request ( $signed_request )
546  
547 Allows the decoding of signed requests for canvas applications to ensure data passed back from Facebook isn't tampered with. You can read more about this at L<http://developers.facebook.com/docs/authentication/canvas>.
548  
549 =head3 $signed_request
550  
551 A signature string passed from Facebook. To capture a signed request your app must be displayed within the Facebook canvas page and then you must pull the query parameter called C<signed_request> from the query string.
552  
553 B<NOTE:> To get this passed to your app you must enable it in your migration settings for your app (L<http://www.facebook.com/developers/>).
554  
555 =head1 EXCEPTIONS
556  
557 This module throws exceptions when it encounters a problem. It uses L<Ouch> to throw the exception, and the Exception typically takes 3 parts: code, message, and a data portion that is the URI that was originally requested. For example:
558  
559 eval { $fb->call_some_method };
560 if (kiss 500) {
561 say "error: ". $@->message;
562 say "uri: ".$@->data;
563 }
564 else {
565 throw $@; # rethrow the error
566 }
567  
568 =head1 CAVEATS
569  
570 The Facebook Graph API is a constantly moving target. As such some stuff that used to work, may stop working. Keep up to date with their changes here: L<https://developers.facebook.com/docs/apps/upgrading>
571  
572 If you were using any version of Facebook::Graph before 1.1000, then you may be used to doing things like creating events through this API, or using a person's username instead of their ID, or making queries without an access token. You can't do any of those things anymore, because as of the Facebook Graph v2.0 API, none of them is supported any longer.
573  
574  
575 =head1 PREREQS
576  
577 L<Moo>
578 L<JSON>
579 L<LWP::UserAgent>
580 L<LWP::Protocol::https>
581 L<URI>
582 L<DateTime>
583 L<DateTime::Format::Strptime>
584 L<MIME::Base64::URLSafe>
585 L<Ouch>
586  
587 =head2 Optional
588  
589 L<Digest::SHA> is used for signed requests. If you don't plan on using the signed request feature, then you do not need to install Digest::SHA.
590  
591 =head1 SUPPORT
592  
593 =over
594  
595 =item Repository
596  
597 L<http://github.com/rizen/Facebook-Graph>
598  
599 =item Bug Reports
600  
601 L<http://github.com/rizen/Facebook-Graph/issues>
602  
603 =back
604  
605  
606 =head1 SEE ALSO
607  
608 I highly recommend L<Facebook::OpenGraph>. I may even switch to it myself soon.
609  
610  
611 =head1 AUTHOR
612  
613 JT Smith <jt_at_plainblack_dot_com>
614  
615 =head1 LEGAL
616  
617 Facebook::Graph is Copyright 2010 - 2017 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself.
618  
619 =cut
« Graph/BatchRequests.pm ↑ Summary Graph/Response.pm »