| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Technorati::SearchApiQuery; |
|
2
|
1
|
|
|
1
|
|
11
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
713
|
use WebService::Technorati::ApiQuery; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use WebService::Technorati::SearchTerm; |
|
7
|
|
|
|
|
|
|
use WebService::Technorati::SearchMatch; |
|
8
|
|
|
|
|
|
|
use WebService::Technorati::Exception; |
|
9
|
|
|
|
|
|
|
use base 'WebService::Technorati::ApiQuery'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use constant API_URI => '/cosmos'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
|
14
|
|
|
|
|
|
|
use vars qw ($VERSION $DEBUG); |
|
15
|
|
|
|
|
|
|
$VERSION = 0.04; |
|
16
|
|
|
|
|
|
|
$DEBUG = 0; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
|
20
|
|
|
|
|
|
|
my ($class, %params) = @_; |
|
21
|
|
|
|
|
|
|
if (! exists $params{'key'}) { |
|
22
|
|
|
|
|
|
|
WebService::Technorati::InstantiationException->throw( |
|
23
|
|
|
|
|
|
|
"WebService::Technorati::SearchApiQuery must be " . |
|
24
|
|
|
|
|
|
|
"instantiated with at least 'key => theverylongkeystring'"); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
my $data = {}; |
|
27
|
|
|
|
|
|
|
if (! exists $params{'url'}) { |
|
28
|
|
|
|
|
|
|
$data->{'needs_url'}++; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
for my $k (keys %params) { |
|
31
|
|
|
|
|
|
|
$data->{'args'}{$k} = $params{$k}; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
my $self = bless ($data, ref ($class) || $class); |
|
34
|
|
|
|
|
|
|
return $self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub url { |
|
38
|
|
|
|
|
|
|
my $self = shift; |
|
39
|
|
|
|
|
|
|
my $url = shift; |
|
40
|
|
|
|
|
|
|
if ($url) { |
|
41
|
|
|
|
|
|
|
$self->{'url'} = $url; |
|
42
|
|
|
|
|
|
|
delete($self->{'needs_url'}); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
return $self->{'url'}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub execute { |
|
48
|
|
|
|
|
|
|
my $self = shift; |
|
49
|
|
|
|
|
|
|
my $apiUrl = $self->apiHostUrl() . API_URI; |
|
50
|
|
|
|
|
|
|
if (exists $self->{'needs_url'}) { |
|
51
|
|
|
|
|
|
|
WebService::Technorati::StateValidationException->throw( |
|
52
|
|
|
|
|
|
|
"WebService::Technorati::AuthorinfoApiQuery must have a " . |
|
53
|
|
|
|
|
|
|
"'url' attribute set prior to query execution"); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
$self->SUPER::execute($apiUrl,$self->{'args'}); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub readResults { |
|
59
|
|
|
|
|
|
|
my $self = shift; |
|
60
|
|
|
|
|
|
|
my $result_xp = shift; |
|
61
|
|
|
|
|
|
|
my $error = $result_xp->find('/tapi/document/result/error'); |
|
62
|
|
|
|
|
|
|
if ($error) { |
|
63
|
|
|
|
|
|
|
WebService::Technorati::DataException->throw($error); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
my $nodeset = $result_xp->find("/tapi/document/result"); |
|
66
|
|
|
|
|
|
|
my $node = $nodeset->shift; |
|
67
|
|
|
|
|
|
|
my $searchTerm = WebService::Technorati::SearchTerm->new_from_node($node); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$nodeset = $result_xp->find('/tapi/document/item'); |
|
70
|
|
|
|
|
|
|
my @matches = (); |
|
71
|
|
|
|
|
|
|
for my $node ($nodeset->get_nodelist) { |
|
72
|
|
|
|
|
|
|
my $match = WebService::Technorati::SearchMatch->new_from_node($node); |
|
73
|
|
|
|
|
|
|
push(@matches, $match); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
$self->{'subject'} = $searchTerm; |
|
76
|
|
|
|
|
|
|
$self->{'matches'} = \@matches; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 getSubjectSearchTerm |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Usage : getSubjectSearchTerm(); |
|
84
|
|
|
|
|
|
|
Purpose : |
|
85
|
|
|
|
|
|
|
Returns : a scalar WebService::Technorati::SearchTerm instance |
|
86
|
|
|
|
|
|
|
Argument : none |
|
87
|
|
|
|
|
|
|
Throws : none |
|
88
|
|
|
|
|
|
|
Comments : call this to retrieve the search invocation metadata |
|
89
|
|
|
|
|
|
|
See Also : WebService::Technorati |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub getSubjectSearchTerm { |
|
94
|
|
|
|
|
|
|
my $self = shift; |
|
95
|
|
|
|
|
|
|
return $self->{'subject'}; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 getClaimedBlogs |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Usage : getClaimedBlogs(); |
|
102
|
|
|
|
|
|
|
Purpose : |
|
103
|
|
|
|
|
|
|
Returns : an array of WebService::Technorati::SearchMatch instances |
|
104
|
|
|
|
|
|
|
Argument : none |
|
105
|
|
|
|
|
|
|
Throws : none |
|
106
|
|
|
|
|
|
|
Comments : the search matches are returned with what Technorati |
|
107
|
|
|
|
|
|
|
knows about them |
|
108
|
|
|
|
|
|
|
See Also : WebService::Technorati |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub getSearchMatches { |
|
113
|
|
|
|
|
|
|
my $self = shift; |
|
114
|
|
|
|
|
|
|
return (wantarray) ? @{$self->{'matches'}} : $self->{'matches'}; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |