source: perl/modules/Facebook/lib/Facebook/Graph/AccessToken/Response.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: 1.8 KB
RevLine 
[cfca761]1package Facebook::Graph::AccessToken::Response;
2BEGIN {
3  $Facebook::Graph::AccessToken::Response::VERSION = '1.0300';
4}
5
6use Any::Moose;
7use URI;
8use URI::QueryParam;
9use Ouch;
10
11has response => (
12    is      => 'ro',
13    required=> 1,
14);
15
16has 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
31has 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
46no Any::Moose;
47__PACKAGE__->meta->make_immutable;
48
49=head1 NAME
50
51Facebook::Graph::AccessToken::Response - The Facebook access token request response.
52
53=head1 VERSION
54
55version 1.0300
56
57=head1 Description
58
59You'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
65Returns the token string.
66
67=head2 expires ()
68
69Returns the time alotted to this token. If undefined then the token is forever.
70
71=head2 response ()
72
73Direct access to the L<HTTP::Response> object.
74
75=head1 LEGAL
76
77Facebook::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.