| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::WhitePages; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1469
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
43
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
58
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '1.05'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
872
|
use LWP::Simple qw($ua get); |
|
|
1
|
|
|
|
|
78639
|
|
|
|
1
|
|
|
|
|
13
|
|
|
9
|
1
|
|
|
1
|
|
1421
|
use Params::Validate qw(validate); |
|
|
1
|
|
|
|
|
87145
|
|
|
|
1
|
|
|
|
|
72
|
|
|
10
|
1
|
|
|
1
|
|
9
|
use URI; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use constant API_BASE => 'http://api.whitepages.com'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
555
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constructor -- simply stores everything given to it |
|
15
|
|
|
|
|
|
|
sub new { |
|
16
|
1
|
|
|
1
|
0
|
1360
|
my $class = shift; |
|
17
|
1
|
50
|
33
|
|
|
14
|
my $args = @_ && ref($_[0]) eq 'HASH' ? shift : { @_ }; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
10
|
$ua->agent("$class/$VERSION (" . $ua->agent . ")"); |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
332
|
bless { |
|
22
|
|
|
|
|
|
|
DEBUG => 0, |
|
23
|
|
|
|
|
|
|
TOKEN => $ENV{'WHITEPAGES_TOKEN'}, |
|
24
|
|
|
|
|
|
|
API_VERSION => '1.0', |
|
25
|
|
|
|
|
|
|
%$args, |
|
26
|
|
|
|
|
|
|
} => $class; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
30
|
|
|
|
|
|
|
# find_person() |
|
31
|
|
|
|
|
|
|
# |
|
32
|
|
|
|
|
|
|
# http://developer.whitepages.com/docs/Methods/find_person |
|
33
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
34
|
|
|
|
|
|
|
sub find_person { |
|
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
36
|
0
|
|
|
|
|
|
return $self->_request( |
|
37
|
|
|
|
|
|
|
validate(@_, { |
|
38
|
|
|
|
|
|
|
'firstname' => 0, |
|
39
|
|
|
|
|
|
|
'lastname' => 1, |
|
40
|
|
|
|
|
|
|
'house' => 0, |
|
41
|
|
|
|
|
|
|
'street' => 0, |
|
42
|
|
|
|
|
|
|
'city' => 0, |
|
43
|
|
|
|
|
|
|
'state' => 0, |
|
44
|
|
|
|
|
|
|
'zip' => 0, |
|
45
|
|
|
|
|
|
|
'areacode' => 0, |
|
46
|
|
|
|
|
|
|
'metro' => 0, |
|
47
|
|
|
|
|
|
|
}) |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
52
|
|
|
|
|
|
|
# reverse_phone |
|
53
|
|
|
|
|
|
|
# |
|
54
|
|
|
|
|
|
|
# http://developer.whitepages.com/docs/Methods/reverse_phone |
|
55
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
56
|
|
|
|
|
|
|
sub reverse_phone { |
|
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
58
|
0
|
|
|
|
|
|
return $self->_request( |
|
59
|
|
|
|
|
|
|
validate(@_, { |
|
60
|
|
|
|
|
|
|
'phone' => 1, |
|
61
|
|
|
|
|
|
|
'state' => 0, |
|
62
|
|
|
|
|
|
|
}), |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
67
|
|
|
|
|
|
|
# reverse_address |
|
68
|
|
|
|
|
|
|
# |
|
69
|
|
|
|
|
|
|
# http://developer.whitepages.com/docs/Methods/reverse_address |
|
70
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
71
|
|
|
|
|
|
|
sub reverse_address { |
|
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
73
|
0
|
|
|
|
|
|
return $self->_request( |
|
74
|
|
|
|
|
|
|
validate(@_, { |
|
75
|
|
|
|
|
|
|
'house' => 0, |
|
76
|
|
|
|
|
|
|
'apt' => 0, |
|
77
|
|
|
|
|
|
|
'street' => 1, |
|
78
|
|
|
|
|
|
|
'city' => 0, |
|
79
|
|
|
|
|
|
|
'state' => 0, |
|
80
|
|
|
|
|
|
|
'zip' => 0, |
|
81
|
|
|
|
|
|
|
'areacode' => 0, |
|
82
|
|
|
|
|
|
|
}), |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Make the URI |
|
87
|
|
|
|
|
|
|
# Takes API_BASE, $self->{ API_VERSION }, and caller |
|
88
|
|
|
|
|
|
|
sub _uri { |
|
89
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
90
|
0
|
|
|
|
|
|
my $meth = shift; |
|
91
|
0
|
|
|
|
|
|
my %p = @_; |
|
92
|
0
|
|
|
|
|
|
my $uri = URI->new(API_BASE . '/' . $meth . '/' . $self->{ API_VERSION }); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $t = $self->{ TOKEN } || |
|
95
|
0
|
|
0
|
|
|
|
die "No token defined; can't make a request without a token!\n"; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$p{'api_key'} = $t; |
|
98
|
0
|
|
|
|
|
|
$p{'outputtype'} = 'Perl'; |
|
99
|
0
|
|
|
|
|
|
$uri->query_form(%p); |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $uri; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Do the actual request against the whitepages.com server |
|
105
|
|
|
|
|
|
|
sub _request { |
|
106
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
107
|
0
|
|
|
|
|
|
my @meth = caller(1); |
|
108
|
0
|
|
|
|
|
|
(my $meth = $meth[3]) =~ s/.*:://; |
|
109
|
0
|
|
|
|
|
|
my $uri = $self->_uri($meth, @_); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ($self->{ DEBUG }) { |
|
112
|
0
|
|
|
|
|
|
warn "[DEBUG] Calling `", $uri->canonical, "'\n"; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $data = get($uri->canonical); |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return eval($data); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |