| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pikeo::API::Photos; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
38481
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
229
|
|
|
4
|
4
|
|
|
4
|
|
27
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
153
|
|
|
5
|
4
|
|
|
4
|
|
24
|
use base qw( Pikeo::API::Base ); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
2049
|
|
|
6
|
4
|
|
|
4
|
|
29
|
use Carp; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
251
|
|
|
7
|
4
|
|
|
4
|
|
4424
|
use XML::LibXML; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XML::LibXML::XPathContext; |
|
9
|
|
|
|
|
|
|
use Pikeo::API::Photo; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Pikeo::API::Photos |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Pikeo::API; |
|
18
|
|
|
|
|
|
|
use Pikeo::API::Photos; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# create an API object to maintain you session |
|
21
|
|
|
|
|
|
|
# trough out the diferent calls |
|
22
|
|
|
|
|
|
|
my $api = Pikeo::API->new({secret=>'asd', key=>'asdas'}); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Create the Photos facade |
|
25
|
|
|
|
|
|
|
my $photos = Pikeo::API::Photos->new({ api => $api }); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Search for photos |
|
28
|
|
|
|
|
|
|
$photos_searched = $photos->search({ text=>'shozu', num_items=>5 }); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This modules provides an interface to the pikeo API photos searching methods. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The methods normally return a list of Pikeo::API::Photo objects. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 new( \%args ) |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns a Pikeo::API::Photos object. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Required args are: |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * api |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The Pikeo::API object used to interact with the pikeo API |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 INSTANCE METHODS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 getMostViewed(\%args) |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
(pikeo.photos.getMostViewed) |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Gets most viewed public photos from the whole photo repository. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns a list of Pikeo::API::Photo objects |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Optional args: |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 4 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * num_items |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Maximum number of items to return. Default 100, maximum 500. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub getMostViewed { |
|
77
|
|
|
|
|
|
|
my $self = shift; |
|
78
|
|
|
|
|
|
|
my $params = shift; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $req_params = {}; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
if ( $params->{'num_items'} ) { |
|
83
|
|
|
|
|
|
|
$req_params->{'num_items'} = $params->{'num_items'}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.photos.getMostViewed', $req_params ); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return $self->_photos_from_xml({ xml => [$doc->findnodes('//photo')] }); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head3 search(\%args) |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
(pikeo.photos.search) |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Search photos which title or associated tags contains a given text, or that match with all different criteria sent in parameters. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns a list of Pikeo::API::Photo objects |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Optional args: |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * num_items |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Maximum number of items to return. Default 100, maximum 500. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * text |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The text to search in photo title or tag name, must contain at least 3 characters |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * offset |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Number of the first element to return. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * user_id |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Select photos for this user Id |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * user |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Select photos for this user |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * album_id |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Select photos for this album Id |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * album |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Select photos for this album |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * group_id |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Select photos for this group id |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * include_contact_photos |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Boolean, Include photos from contacts too |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * only_public |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Boolean, Filter to public photos only |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * order_asc |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Boolean, Acsendant or descendant order |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * order_type |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Order Type : |
|
151
|
|
|
|
|
|
|
0 by default, |
|
152
|
|
|
|
|
|
|
1 by date taken, |
|
153
|
|
|
|
|
|
|
2 by upload date, |
|
154
|
|
|
|
|
|
|
3 by most viewed, |
|
155
|
|
|
|
|
|
|
4 by comment date, |
|
156
|
|
|
|
|
|
|
5 by group add date. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * tag_id_list |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Reference to an array |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Select photos for this list of tag id |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * high_date |
|
165
|
|
|
|
|
|
|
=item * end_date |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Select photos which date is before this date |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Date format: 2008-01-29 10:00:53 |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * low_date |
|
172
|
|
|
|
|
|
|
=item * start_date |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Select photos which date is after this date |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Date format: 2008-01-29 10:00:53 |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub search { |
|
183
|
|
|
|
|
|
|
my $self = shift; |
|
184
|
|
|
|
|
|
|
my $params = shift; |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
my $req_params = {}; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
for my $p ( qw( text num_items offset user_id album_id group_id |
|
189
|
|
|
|
|
|
|
only_public order_type order_asc include_contact_photos ) ) { |
|
190
|
|
|
|
|
|
|
$req_params->{$p} = $params->{$p} if $params->{$p}; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
if ( $params->{'user'} ) { |
|
193
|
|
|
|
|
|
|
$req_params->{'user_id'} = $params->{'user'}->id(); |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
$params->{'end_date'} = $params->{'high_date'} if $params->{'high_date'}; |
|
197
|
|
|
|
|
|
|
if ( $params->{'end_date'} ) { |
|
198
|
|
|
|
|
|
|
$req_params->{'high_date'} = $params->{'end_date'}; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
$params->{'start_date'} = $params->{'low_date'} if $params->{'low_date'}; |
|
201
|
|
|
|
|
|
|
if ( $params->{'start_date'} ) { |
|
202
|
|
|
|
|
|
|
$req_params->{'low_date'} = $params->{'start_date'}; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
if ( $params->{'album'} ) { |
|
205
|
|
|
|
|
|
|
$req_params->{'album_id'} = $params->{'album'}->id(); |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
if ( $params->{'tag_id_list'} ) { |
|
209
|
|
|
|
|
|
|
$req_params->{'tag_id_list'} = '[' . join(',',@{$params->{'tag_id_list'}}) . ']'; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.photos.search', $req_params ); |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
return $self->_photos_from_xml({ xml => [$doc->findnodes('//photo')] }); |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |