| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Flickr::API::Request; |
|
2
|
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
102
|
use strict; |
|
|
15
|
|
|
|
|
25
|
|
|
|
15
|
|
|
|
|
628
|
|
|
4
|
15
|
|
|
15
|
|
78
|
use warnings; |
|
|
15
|
|
|
|
|
71
|
|
|
|
15
|
|
|
|
|
939
|
|
|
5
|
15
|
|
|
15
|
|
115
|
use HTTP::Request; |
|
|
15
|
|
|
|
|
30
|
|
|
|
15
|
|
|
|
|
645
|
|
|
6
|
15
|
|
|
15
|
|
8123
|
use Net::OAuth; |
|
|
15
|
|
|
|
|
12107
|
|
|
|
15
|
|
|
|
|
597
|
|
|
7
|
15
|
|
|
15
|
|
112
|
use URI; |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
474
|
|
|
8
|
15
|
|
|
15
|
|
72
|
use Encode qw(encode_utf8); |
|
|
15
|
|
|
|
|
31
|
|
|
|
15
|
|
|
|
|
1548
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
15
|
|
|
15
|
|
106
|
use parent qw(HTTP::Request); |
|
|
15
|
|
|
|
|
26
|
|
|
|
15
|
|
|
|
|
140
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.28'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
2
|
|
|
2
|
1
|
5
|
my $class = shift; |
|
16
|
2
|
|
|
|
|
24
|
my $options = shift; |
|
17
|
2
|
|
|
|
|
5
|
my $self; |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
50
|
50
|
|
|
13
|
if (($options->{api_type} || '') eq 'oauth') { |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
$options->{args}->{request_method}='POST'; |
|
22
|
0
|
|
|
|
|
0
|
$options->{args}->{request_url}=$options->{rest_uri}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
my $orequest; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
0
|
if (defined($options->{args}->{token})) { |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
$orequest = Net::OAuth->request('protected resource')->new(%{$options->{args}}); |
|
|
0
|
|
|
|
|
0
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
else { |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
$orequest = Net::OAuth->request('consumer')->new(%{$options->{args}}); |
|
|
0
|
|
|
|
|
0
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
$orequest->sign(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
my $h = HTTP::Headers->new; |
|
42
|
0
|
|
|
|
|
0
|
$h->header('Content-Type' => 'application/x-www-form-urlencoded'); |
|
43
|
0
|
|
|
|
|
0
|
$h->header('Content-Length' => length($orequest->to_post_body)); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self = HTTP::Request->new( |
|
46
|
|
|
|
|
|
|
$options->{args}->{request_method}, |
|
47
|
|
|
|
|
|
|
$options->{rest_uri}, |
|
48
|
0
|
|
|
|
|
0
|
$h, |
|
49
|
|
|
|
|
|
|
$orequest->to_post_body()); |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
$self->{api_method} = $options->{method}; |
|
52
|
0
|
|
|
|
|
0
|
$self->{api_type} = $options->{api_type}; |
|
53
|
0
|
|
0
|
|
|
0
|
$self->{unicode} = $options->{unicode} || 0; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
else { |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
22
|
$self = HTTP::Request->new; |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
170
|
$self->{api_method} = $options->{method}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
2
|
|
50
|
|
|
12
|
$self->{api_type} = $options->{api_type} || 'flickr'; |
|
63
|
2
|
|
50
|
|
|
12
|
$self->{unicode} = $options->{unicode} || 0; |
|
64
|
2
|
|
|
|
|
6
|
$self->{api_args} = $options->{args}; |
|
65
|
2
|
|
50
|
|
|
7
|
$self->{rest_uri} = $options->{rest_uri} || 'https://api.flickr.com/services/rest/'; |
|
66
|
2
|
|
|
|
|
9
|
$self->method('POST'); |
|
67
|
2
|
|
|
|
|
24
|
$self->uri($self->{rest_uri}); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
13379
|
bless $self, $class; |
|
72
|
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
9
|
return $self; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub encode_args { |
|
77
|
2
|
|
|
2
|
0
|
6
|
my ($self) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
4
|
my $content; |
|
80
|
2
|
|
|
|
|
10
|
my $url = URI->new('https:'); |
|
81
|
|
|
|
|
|
|
|
|
82
|
2
|
50
|
|
|
|
156
|
if ($self->{unicode}){ |
|
83
|
0
|
|
|
|
|
0
|
for my $k(keys %{$self->{api_args}}){ |
|
|
0
|
|
|
|
|
0
|
|
|
84
|
0
|
|
|
|
|
0
|
$self->{api_args}->{$k} = encode_utf8($self->{api_args}->{$k}); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
2
|
|
|
|
|
4
|
$url->query_form(%{$self->{api_args}}); |
|
|
2
|
|
|
|
|
38
|
|
|
88
|
2
|
|
|
|
|
435
|
$content = $url->query; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
47
|
$self->header('Content-Type' => 'application/x-www-form-urlencoded'); |
|
92
|
2
|
50
|
|
|
|
260
|
if (defined($content)) { |
|
93
|
2
|
|
|
|
|
12
|
$self->header('Content-Length' => length($content)); |
|
94
|
2
|
|
|
|
|
163
|
$self->content($content); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
2
|
|
|
|
|
76
|
return; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |