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:
1.8 KB
|
Line | |
---|
1 | package Facebook::Graph::AccessToken::Response; |
---|
2 | BEGIN { |
---|
3 | $Facebook::Graph::AccessToken::Response::VERSION = '1.0300'; |
---|
4 | } |
---|
5 | |
---|
6 | use Any::Moose; |
---|
7 | use URI; |
---|
8 | use URI::QueryParam; |
---|
9 | use Ouch; |
---|
10 | |
---|
11 | has response => ( |
---|
12 | is => 'ro', |
---|
13 | required=> 1, |
---|
14 | ); |
---|
15 | |
---|
16 | has token => ( |
---|
17 | is => 'ro', |
---|
18 | lazy => 1, |
---|
19 | default => sub { |
---|
20 | my $self = shift; |
---|
21 | my $response = $self->response; |
---|
22 | if ($response->is_success) { |
---|
23 | return URI->new('?'.$response->content)->query_param('access_token'); |
---|
24 | } |
---|
25 | else { |
---|
26 | ouch $response->code, 'Could not fetch access token: '.$response->message, $response->request->uri->as_string; |
---|
27 | } |
---|
28 | } |
---|
29 | ); |
---|
30 | |
---|
31 | has expires => ( |
---|
32 | is => 'ro', |
---|
33 | lazy => 1, |
---|
34 | default => sub { |
---|
35 | my $self = shift; |
---|
36 | my $response = $self->response; |
---|
37 | if ($response->is_success) { |
---|
38 | return URI->new('?'.$response->content)->query_param('expires'); |
---|
39 | } |
---|
40 | else { |
---|
41 | ouch $response->code, 'Could not fetch access token: '.$response->message, $response->request->uri->as_string; |
---|
42 | } |
---|
43 | } |
---|
44 | ); |
---|
45 | |
---|
46 | no Any::Moose; |
---|
47 | __PACKAGE__->meta->make_immutable; |
---|
48 | |
---|
49 | =head1 NAME |
---|
50 | |
---|
51 | Facebook::Graph::AccessToken::Response - The Facebook access token request response. |
---|
52 | |
---|
53 | =head1 VERSION |
---|
54 | |
---|
55 | version 1.0300 |
---|
56 | |
---|
57 | =head1 Description |
---|
58 | |
---|
59 | You'll be given one of these as a result of calling the C<request> method from a L<Facebook::Graph::AccessToken> object. |
---|
60 | |
---|
61 | =head1 METHODS |
---|
62 | |
---|
63 | =head2 token () |
---|
64 | |
---|
65 | Returns the token string. |
---|
66 | |
---|
67 | =head2 expires () |
---|
68 | |
---|
69 | Returns the time alotted to this token. If undefined then the token is forever. |
---|
70 | |
---|
71 | =head2 response () |
---|
72 | |
---|
73 | Direct access to the L<HTTP::Response> object. |
---|
74 | |
---|
75 | =head1 LEGAL |
---|
76 | |
---|
77 | Facebook::Graph is Copyright 2010 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself. |
---|
78 | |
---|
79 | =cut |
---|
Note: See
TracBrowser
for help on using the repository browser.