line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Facebook.com API Client |
2
|
|
|
|
|
|
|
package API::Facebook; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1464
|
use Data::Object::Class; |
|
1
|
|
|
|
|
25145
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
2365
|
use Data::Object::Signatures; |
|
1
|
|
|
|
|
283646
|
|
|
1
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
|
|
5
|
use Data::Object::Library qw( |
8
|
|
|
|
|
|
|
Str |
9
|
1
|
|
|
1
|
|
9291
|
); |
|
1
|
|
|
|
|
2
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'API::Client'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.04'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $DEFAULT_URL = "https://graph.facebook.com"; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ATTRIBUTES |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has access_token => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => Str, |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# DEFAULTS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has '+identifier' => ( |
28
|
|
|
|
|
|
|
default => 'API::Facebook (Perl)', |
29
|
|
|
|
|
|
|
required => 0, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has '+url' => ( |
33
|
|
|
|
|
|
|
default => $DEFAULT_URL, |
34
|
|
|
|
|
|
|
required => 0, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has '+version' => ( |
38
|
|
|
|
|
|
|
default => 1, |
39
|
|
|
|
|
|
|
required => 0, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# CONSTRUCTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
after BUILD => method { |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $identifier = $self->identifier; |
47
|
|
|
|
|
|
|
my $version = $self->version; |
48
|
|
|
|
|
|
|
my $agent = $self->user_agent; |
49
|
|
|
|
|
|
|
my $url = $self->url; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$agent->transactor->name($identifier); |
52
|
|
|
|
|
|
|
$url->path("/v$version"); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# METHODS |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
0
|
|
method PREPARE ($ua, $tx, %args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $headers = $tx->req->headers; |
63
|
0
|
|
|
|
|
|
my $url = $tx->req->url; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# default headers |
66
|
0
|
|
|
|
|
|
$headers->header('Content-Type' => 'application/json'); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# access token parameter |
69
|
0
|
0
|
|
|
|
|
$url->query->merge(access_token => $self->access_token) if $self->access_token; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
|
method resource (@segments) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# build new resource instance |
76
|
0
|
|
|
|
|
|
my $instance = __PACKAGE__->new( |
77
|
|
|
|
|
|
|
access_token => $self->access_token, |
78
|
|
|
|
|
|
|
debug => $self->debug, |
79
|
|
|
|
|
|
|
fatal => $self->fatal, |
80
|
|
|
|
|
|
|
retries => $self->retries, |
81
|
|
|
|
|
|
|
timeout => $self->timeout, |
82
|
|
|
|
|
|
|
user_agent => $self->user_agent, |
83
|
|
|
|
|
|
|
identifier => $self->identifier, |
84
|
|
|
|
|
|
|
version => $self->version, |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# resource locator |
89
|
0
|
|
|
|
|
|
my $url = $instance->url; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# modify resource locator if possible |
92
|
0
|
|
|
|
|
|
$url->path(join '/', $self->url->path, @segments); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# return resource instance |
95
|
0
|
|
|
|
|
|
return $instance; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |