line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Net::Google::Service - SOAP widget(s) for Net::Google |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Net::Google::Service; |
8
|
|
|
|
|
|
|
my $search = Net::Google::Service->search({debug=>1}); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
SOAP widget(s) for Net::Google |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Net::Google::Service; |
17
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
127
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$Net::Google::Service::VERSION = '1.0'; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
1940
|
use SOAP::Lite; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Carp; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# This clever hack is courtesy Matt Webb: |
25
|
|
|
|
|
|
|
# http://interconnected.org/home/more/GoogleSearch.pl.txt |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Redefine how the default deserializer handles booleans. |
28
|
|
|
|
|
|
|
# Workaround because the 1999 schema implementation incorrectly doesn't |
29
|
|
|
|
|
|
|
# accept "true" and "false" for boolean values. |
30
|
|
|
|
|
|
|
# See http://groups.yahoo.com/group/soaplite/message/895 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
*SOAP::XMLSchema1999::Deserializer::as_boolean = |
33
|
|
|
|
|
|
|
*SOAP::XMLSchemaSOAP1_1::Deserializer::as_boolean = |
34
|
|
|
|
|
|
|
\&SOAP::XMLSchema2001::Deserializer::as_boolean; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use constant SERVICES => { |
37
|
|
|
|
|
|
|
"cache" => "GoogleSearch.wsdl", |
38
|
|
|
|
|
|
|
"search" => "GoogleSearch.wsdl", |
39
|
|
|
|
|
|
|
"spelling" => "GoogleSearch.wsdl", |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use constant SERVICE_CACHE => {}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 __PACKAGE__->search(\%args) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub search { |
51
|
|
|
|
|
|
|
my $pkg = shift; |
52
|
|
|
|
|
|
|
return $pkg->_soap("search",@_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 __PACKAGE__->spelling(\%args) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub spelling { |
60
|
|
|
|
|
|
|
my $pkg = shift; |
61
|
|
|
|
|
|
|
return $pkg->_soap("spelling",@_); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 __PACKAGE_->cache(\%args) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub cache { |
69
|
|
|
|
|
|
|
my $pkg = shift; |
70
|
|
|
|
|
|
|
return $pkg->_soap("cache",@_); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Private methods |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _soap { |
76
|
|
|
|
|
|
|
my $pkg = shift; |
77
|
|
|
|
|
|
|
my $service = shift; |
78
|
|
|
|
|
|
|
my $args = shift; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $soap = SOAP::Lite->service("file:".__PACKAGE__->_service($service)); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
if ($args->{'http_proxy'}) { |
83
|
|
|
|
|
|
|
# Get the SOAP transport object |
84
|
|
|
|
|
|
|
# Then get its proxy object (note the args) |
85
|
|
|
|
|
|
|
# Which is really just an LWP::UserAgent |
86
|
|
|
|
|
|
|
# so we get that and set the args (again) |
87
|
|
|
|
|
|
|
$soap->transport()->proxy($args->{'http_proxy'})->proxy(http=>$args->{'http_proxy'}); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
if ($args->{'debug'}) { |
91
|
|
|
|
|
|
|
SOAP::Trace->import(debug=>((ref($args->{debug}) eq "CODE") ? $args->{'debug'} : sub {print STDERR @_})); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$soap->on_fault(sub{ |
95
|
|
|
|
|
|
|
my ($soap,$res) = @_; |
96
|
|
|
|
|
|
|
my $err = (ref($res)) ? $res->faultstring() : $soap->transport()->status(); |
97
|
|
|
|
|
|
|
carp $err; |
98
|
|
|
|
|
|
|
return undef; |
99
|
|
|
|
|
|
|
}); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
return $soap; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _service { |
105
|
|
|
|
|
|
|
my $pkg = shift; |
106
|
|
|
|
|
|
|
my $service = shift; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# This is not the droid you're looking for. |
109
|
|
|
|
|
|
|
# We're talking to the constants this way |
110
|
|
|
|
|
|
|
# for two reasons : |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# 1) The SERVICE_CACHE->{foo} syntax causes Perl |
113
|
|
|
|
|
|
|
# Perl 5.00502 to break since the "inlined |
114
|
|
|
|
|
|
|
# subroutined-ness" of scalar constants |
115
|
|
|
|
|
|
|
# https://rt.cpan.org/Ticket/Display.html?id=1753 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# 2) Rather than creating a whole bunch of separate |
118
|
|
|
|
|
|
|
# subroutines to abstract away all the ($] > 5.00502) |
119
|
|
|
|
|
|
|
# stuff, I might as well just tack the '&' on |
120
|
|
|
|
|
|
|
# now and be done with it. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
if (exists &SERVICE_CACHE->{$service}) { |
123
|
|
|
|
|
|
|
return &SERVICE_CACHE->{$service} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
foreach my $dir (@INC) { |
127
|
|
|
|
|
|
|
if (-f "$dir/Net/Google/Services/".&SERVICES->{$service}) { |
128
|
|
|
|
|
|
|
&SERVICE_CACHE->{$service} = "$dir/Net/Google/Services/".&SERVICES->{$service}; |
129
|
|
|
|
|
|
|
return &SERVICE_CACHE->{$service}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
return undef; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 VERSION |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1.0 |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DATE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
$Date: 2005/03/26 20:49:03 $ |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Aaron Straup Cope |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright (c) 2002-2005, Aaron Straup Cope. All Rights Reserved. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software, you may use it and distribute it under the same terms as Perl itself. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
return 1; |