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