| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pikeo::API::User::Logged; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21055
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
81
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
63
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
163
|
|
|
6
|
2
|
|
|
2
|
|
1947
|
use MIME::Base64; |
|
|
2
|
|
|
|
|
1700
|
|
|
|
2
|
|
|
|
|
141
|
|
|
7
|
2
|
|
|
2
|
|
654
|
use Pikeo::API::Photo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Pikeo::API::Contact; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw( Pikeo::API::User ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
896
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
|
|
sub _info_fields { qw( real_name location avatar_url username email |
|
13
|
|
|
|
|
|
|
profile_url birthday blog_url |
|
14
|
|
|
|
|
|
|
) } |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Pikeo::API::User::Logged - Abstraction the logged in pikeo user |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This modules provides an interface to the logged in user in pikeo. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This module inherits from Pikeo::API::User so all the methods of |
|
25
|
|
|
|
|
|
|
Pikeo::API::User are also available. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Pikeo::API; |
|
30
|
|
|
|
|
|
|
use Pikeo::API::User::Logged; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# create an API object to maintain you session |
|
33
|
|
|
|
|
|
|
# trough out the diferent calls |
|
34
|
|
|
|
|
|
|
my $api = Pikeo::API->new({api_secret=>'asd', api_key=>'asdas'}); |
|
35
|
|
|
|
|
|
|
$api->login({ username => 'a', password => 'b' }); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Get the logged in user |
|
38
|
|
|
|
|
|
|
my $user1 = Pikeo::API::User::Logged->new({ api => $api }); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#get the public photos |
|
41
|
|
|
|
|
|
|
my $photos = $user->getPublicPhotos(); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head3 new( \%args ) |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns a Pikeo::API::User object. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Required args are: |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * api |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Pikeo::API object |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub new { |
|
64
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
65
|
0
|
|
|
|
|
|
my $params= shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
croak "need an api" unless $params->{api}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
croak "you must be logged in" unless $params->{api}->is_logged_in(); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $self = bless { _init_done => 1, _api => $params->{api} }, $class; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $doc = $params->{api}->request_parsed('pikeo.people.getMyInfo',{}); |
|
74
|
0
|
|
|
|
|
|
for ( @{$doc->findnodes('/response/my_person/*')} ) { |
|
|
0
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
$self->{$_->nodeName} = ( $_->to_literal eq 'null' ? undef : $_->to_literal ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
croak "could not instantiate current user" unless $self->id; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 INSTANCE METHODS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head3 uploadPhoto(\%args) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Upload one photo to the photo repository |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the Pikeo::API::Photo object representing the uploaded photo |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Required args: |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * picture |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
One file name containing the picture or a IO::File object pointing to the picture |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Optional args: |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * title |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The picture title |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * access_type |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The access type of the picture: 0 for PRIVATE, 2 for FRIEND, 4 for FAMILY, 6 for FRIEND AND FAMILY and 7 for PUBLIC. By default the picture is PUBLIC |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * title |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Title associated to the photo |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * description |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Description of the photo |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
A list of tags associated to the uploaded photo |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The list of tags is a reference to an array containing 'category' => 'tag' pairs. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Example: [ 'where' => 'lisbon', 'who' => 'donald' , ... ] |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Tag categories can be: who, what or where. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Only letters, figures and spaces are authorized in the tag itself. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub uploadPhoto { |
|
140
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
141
|
0
|
|
|
|
|
|
my $params = shift; |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
0
|
0
|
|
|
|
my $req_params = { |
|
|
|
|
0
|
|
|
|
|
|
144
|
|
|
|
|
|
|
title => $params->{title} || '', |
|
145
|
|
|
|
|
|
|
access_type => (defined($params->{access_type}) ? ($params->{access_type}) : 7), |
|
146
|
|
|
|
|
|
|
description => $params->{description} || '', |
|
147
|
|
|
|
|
|
|
}; |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
croak "missing required param 'picture'" |
|
150
|
|
|
|
|
|
|
unless $params->{picture}; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Is this a file path? |
|
153
|
0
|
0
|
|
|
|
|
if (ref($params->{picture}) eq '') { |
|
|
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# let's convert this to an IO::File |
|
155
|
0
|
|
|
|
|
|
$params->{picture} = IO::File->new($params->{picture}, 'r'); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
elsif ( ref($params->{picture}) ne 'IO::File' ) { |
|
158
|
0
|
|
|
|
|
|
croak "invalid param format for 'picture'"; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
0
|
|
|
|
|
|
$req_params->{picture} = encode_base64(join('',$params->{picture}->getlines())); |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
if ( $params->{'tags'} ) { |
|
163
|
0
|
|
|
|
|
|
my @tags = (); |
|
164
|
0
|
|
|
|
|
|
while (scalar(@{$params->{'tags'}})) { |
|
|
0
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
push @tags, shift(@{$params->{'tags'}}).":".shift(@{$params->{'tags'}}); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
} |
|
167
|
0
|
|
|
|
|
|
$req_params->{tags} = join(",",@tags); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.photos.upload', $req_params ); |
|
171
|
0
|
|
|
|
|
|
my $photo_id = $doc->findvalue("//value"); |
|
172
|
0
|
0
|
|
|
|
|
croak "Failed to upload photo, no photo id returned" |
|
173
|
|
|
|
|
|
|
unless $photo_id; |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
return Pikeo::API::Photo->new({ id => $photo_id, api => $self->api }); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head3 getMyCommentedPhotos() |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Return all the photos that the user owns that are commented. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Return a list of Pikeo::API::Photo |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub getMyCommentedPhotos { |
|
188
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
189
|
0
|
|
|
|
|
|
my $params = shift; |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $req_params = {}; |
|
192
|
|
|
|
|
|
|
|
|
193
|
0
|
0
|
|
|
|
|
if ( $params->{num_items} ) { |
|
194
|
0
|
|
|
|
|
|
$req_params->{num_items} = $params->{num_items}; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.comments.getMyCommentedPhotos', $req_params ); |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
return $self->_photos_from_xml({ xml => [$doc->findnodes('//photo')] }); |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head3 getPicturesCommentedByMe() |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Returns all the photos that were commented by the user. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Return a list of Pikeo::API::Photo |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub getPicturesCommentedByMe { |
|
211
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
212
|
0
|
|
|
|
|
|
my $params = shift; |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my $req_params = {}; |
|
215
|
|
|
|
|
|
|
|
|
216
|
0
|
0
|
|
|
|
|
if ( $params->{num_items} ) { |
|
217
|
0
|
|
|
|
|
|
$req_params->{num_items} = $params->{num_items}; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.comments.getPicturesCommentedByMe', $req_params ); |
|
221
|
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
return $self->_photos_from_xml({ xml => [$doc->findnodes('//photo')] }); |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head3 getContactsList() |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
The function will get the contacts of the logged user. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Returns a list of Pikeo::API::Contact objects. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub getContactsList { |
|
234
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
235
|
0
|
|
|
|
|
|
my $params = shift; |
|
236
|
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.contacts.getList', {} ); |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
my @contacts = (); |
|
240
|
0
|
|
|
|
|
|
for my $contact (@{ $doc->findnodes('//contact') }) { |
|
|
0
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
push @contacts, Pikeo::API::Contact->new({api=>$self->api, from_xml=>$contact}); |
|
242
|
|
|
|
|
|
|
} |
|
243
|
0
|
|
|
|
|
|
return \@contacts; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
|
247
|
0
|
|
|
0
|
|
|
sub _init { shift->{_init_done} = 1 } |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
1; |