line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Tagzania::API; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
53612
|
use strict ; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
236
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings ; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1076
|
use WebService::Tagzania::Request ; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
59
|
|
7
|
2
|
|
|
2
|
|
1077
|
use WebService::Tagzania::Response ; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
60
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2498
|
use LWP::UserAgent ; |
|
2
|
|
|
|
|
33216
|
|
|
2
|
|
|
|
|
60
|
|
10
|
2
|
|
|
2
|
|
19
|
use Data::Dumper ; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
803
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw ( LWP::UserAgent ) ; |
13
|
|
|
|
|
|
|
our $VERSION = '0.1' ; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 new |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Create a new object for the Tagzania API class. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $tagobj = new WebService::Tagzania::API() ; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
2
|
|
|
2
|
1
|
25
|
my $class = shift ; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
## Please do not change the following parameter. |
29
|
|
|
|
|
|
|
## It does not reveal any personal information |
30
|
|
|
|
|
|
|
## but helps Tagzania in tracking usage of their API |
31
|
|
|
|
|
|
|
## through this module. |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
8
|
my %options = ( 'agent' => 'WebService::Tagzania::API' ) ; |
34
|
2
|
|
|
|
|
22
|
my $self = new LWP::UserAgent ( %options ); |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
6928
|
bless $self, $class ; |
37
|
2
|
|
|
|
|
40
|
return $self ; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 query |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Perform a query to the Tagzania API. Accepts a reference to a hash |
43
|
|
|
|
|
|
|
with the required query arguments. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $rh_params = { |
46
|
|
|
|
|
|
|
'start' => 0, |
47
|
|
|
|
|
|
|
'number' => 10, |
48
|
|
|
|
|
|
|
'minlng' => -9.25, |
49
|
|
|
|
|
|
|
'minlat' => 35.35, |
50
|
|
|
|
|
|
|
'maxlng' => 4.55, |
51
|
|
|
|
|
|
|
'maxlat' => 43.80, |
52
|
|
|
|
|
|
|
} ; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $response = $tagobj->query( $rh_params ) ; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The required parameters are : |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
start => defined the element number of which to start from |
59
|
|
|
|
|
|
|
number => defined the number of total results to return |
60
|
|
|
|
|
|
|
minlng, maxlng, minlat, maxlat => coordinates of bounding box of location to query |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The Tagzania API returns well-formed XML. This will be present in the |
63
|
|
|
|
|
|
|
'_content' key of the response. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub query { |
68
|
1
|
|
|
1
|
1
|
1112
|
my $self = shift ; |
69
|
1
|
|
|
|
|
2
|
my $rh_params = shift ; |
70
|
|
|
|
|
|
|
|
71
|
1
|
50
|
33
|
|
|
20
|
return unless $rh_params |
|
|
|
33
|
|
|
|
|
72
|
|
|
|
|
|
|
&& defined $rh_params |
73
|
|
|
|
|
|
|
&& ref $rh_params eq 'HASH' ; |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
11
|
my $query = new WebService::Tagzania::Request ( $rh_params ) ; |
76
|
|
|
|
|
|
|
|
77
|
1
|
50
|
|
|
|
5
|
if ( defined $query ) { |
78
|
1
|
|
|
|
|
4
|
$self->execute_query($query) ; |
79
|
|
|
|
|
|
|
} else { |
80
|
0
|
|
|
|
|
0
|
return undef ; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 execute_query |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
internal function |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub execute_query { |
91
|
1
|
|
|
1
|
1
|
2
|
my $self = shift ; |
92
|
1
|
|
|
|
|
2
|
my $query = shift ; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
6
|
my $url = $query->encode_arguments() ; |
95
|
0
|
|
|
|
|
|
my $response = $self->get($url) ; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
bless $response, 'WebService::Tagzania::Response' ; |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
unless ($response->{_rc} = 200) { |
100
|
0
|
|
|
|
|
|
$response->set_fail(0, "API returned a non-200 status code: ($response->{_rc})") ; |
101
|
0
|
|
|
|
|
|
return $response ; |
102
|
|
|
|
|
|
|
} ; |
103
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
unless ($response->{_msg} eq 'OK') { |
105
|
0
|
|
|
|
|
|
$response->set_fail(0, "An API error has occured: $response->{_msg}") ; |
106
|
0
|
|
|
|
|
|
return $response ; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $results = $response->{_content} ; |
110
|
0
|
|
|
|
|
|
$response->set_success($results) ; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
return $response ; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 NAME |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
WebService::Tagzania::API - Tagzania API Interface |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SYNOPSIS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
use WebService::Tagzania::API; |
123
|
|
|
|
|
|
|
my $tagobj = new WebService::Tagzania::API() ; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $rh_params = { |
126
|
|
|
|
|
|
|
'start' => 0, |
127
|
|
|
|
|
|
|
'number' => 200, |
128
|
|
|
|
|
|
|
'minlng' => -9.25, |
129
|
|
|
|
|
|
|
'minlat' => 35.35, |
130
|
|
|
|
|
|
|
'maxlng' => 4.55, |
131
|
|
|
|
|
|
|
'maxlat' => 43.80, |
132
|
|
|
|
|
|
|
} ; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $results = $api->query( $rh_params ) ; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my $content = $results->{_content} ; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# do something with the XML inside $content |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DESCRIPTION |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Tagzania is all about tags and places. Tagzania lets you create custom maps, |
143
|
|
|
|
|
|
|
add points of interest on them and share them with other users, all in an extremely |
144
|
|
|
|
|
|
|
easy fashion. This module provides a Perl OO-ish wrapper around the Tagzania.com API. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 BUGS |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
None. |
149
|
|
|
|
|
|
|
That I know of ;) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Spiros Denaxas |
154
|
|
|
|
|
|
|
CPAN ID: SDEN |
155
|
|
|
|
|
|
|
Lokku Ltd |
156
|
|
|
|
|
|
|
s [dot] denaxas [@] gmail [dot]com |
157
|
|
|
|
|
|
|
http://idaru.blogspot.com |
158
|
|
|
|
|
|
|
http://www.nestoria.co.uk |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This program is free software; you can redistribute |
163
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The full text of the license can be found in the |
166
|
|
|
|
|
|
|
LICENSE file included with this module. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L, L, L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
|