line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::FC2::SpamAPI; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
68887
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
63
|
|
5
|
2
|
|
|
2
|
|
10
|
use base qw/ Class::Accessor::Fast /; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
1752
|
|
6
|
2
|
|
|
2
|
|
40926
|
use URI::Fetch; |
|
2
|
|
|
|
|
504756
|
|
|
2
|
|
|
|
|
81
|
|
7
|
2
|
|
|
2
|
|
97
|
use URI; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
8
|
2
|
|
|
2
|
|
2120
|
use URI::QueryParam; |
|
2
|
|
|
|
|
2053
|
|
|
2
|
|
|
|
|
71
|
|
9
|
2
|
|
|
2
|
|
20
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
311
|
|
10
|
2
|
|
|
2
|
|
2157
|
use WebService::FC2::SpamAPI::Response; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
30
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $API_uri = 'http://seo.fc2.com/spam/spamapi.php'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw/ cache / ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
WebService::FC2::SpamAPI - FC2 blog spam API client |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 VERSION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Version 0.02 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Clinet for FC2 spam API. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
http://seo.fc2.com/spam/ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use WebService::FC2::SpamAPI; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $api = WebService::FC2::SpamAPI->new(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$res = $api->check_url('http://spam.example.com'); |
41
|
|
|
|
|
|
|
if ( $res->is_spam ) { .... |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
@res = $api->get_url_list(); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
@res = $api->get_domain_list({ dm => 'foo.example.com' }); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 FUNCTIONS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Constructor. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $api = WebService::FC2::SpamAPI->new(); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# use Cache ( see URI::Fetch ) |
56
|
|
|
|
|
|
|
my $api = WebService::FC2::SpamAPI->new({ cache => $cache_object }); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub new { |
61
|
1
|
|
|
1
|
1
|
14
|
my $class = shift; |
62
|
1
|
|
|
|
|
15
|
my $self = $class->SUPER::new(@_); |
63
|
1
|
|
|
|
|
15
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 check_url |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Check URL for FC2 spam list. |
69
|
|
|
|
|
|
|
Returns WebService::FC2::SpamAPI::Response object. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# simple check |
72
|
|
|
|
|
|
|
$res = $api->check_url('http://xxx.example.com'); |
73
|
|
|
|
|
|
|
if ( $res->is_spam ) { .... |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# returns detailed data |
76
|
|
|
|
|
|
|
# see also http://seo.fc2.com/spam/spamapi.php?m=h |
77
|
|
|
|
|
|
|
$res = $api->check_url({ url => 'http://xxx.exampl.com', |
78
|
|
|
|
|
|
|
usid => 0000, |
79
|
|
|
|
|
|
|
data => 1, }); |
80
|
|
|
|
|
|
|
$res->is_spam; |
81
|
|
|
|
|
|
|
$res->usid; # fc2 userid |
82
|
|
|
|
|
|
|
$res->name; # site name |
83
|
|
|
|
|
|
|
$res->comment; # comment |
84
|
|
|
|
|
|
|
# see WebService::FC2::SpamAPI::Response |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub check_url { |
89
|
2
|
|
|
2
|
1
|
14754
|
my ( $self, $args ) = @_; |
90
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
26
|
my $uri = URI->new( $API_uri ); |
92
|
2
|
100
|
|
|
|
9775
|
if ( !ref $args ) { |
|
|
50
|
|
|
|
|
|
93
|
1
|
|
|
|
|
15
|
$uri->query_param( url => $args ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( ref $args eq 'HASH' ) { |
96
|
1
|
|
|
|
|
5
|
for my $n ( qw/ url data usid / ) { |
97
|
3
|
100
|
|
|
|
301
|
$uri->query_param( $n => $args->{$n} ) |
98
|
|
|
|
|
|
|
if defined $args->{$n}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
0
|
|
|
|
|
0
|
croak('check_url() requires SCALAR or HASH ref arguments.'); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
2
|
|
|
|
|
320
|
my $res = $self->_fetch( $uri ); |
106
|
2
|
50
|
|
|
|
2215048
|
return unless $res; |
107
|
|
|
|
|
|
|
|
108
|
2
|
|
|
|
|
39
|
return WebService::FC2::SpamAPI::Response->parse( $res->content ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 get_url_list |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Get registered spam URL list. |
114
|
|
|
|
|
|
|
Returns WebService::FC2::SpamAPI::Response list. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
@res = $api->get_url_list(); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
@res = $api->get_url_list({ usid => 0000 }); # grep by userid |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub get_url_list { |
123
|
1
|
|
|
1
|
1
|
2004
|
my ( $self, $args ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
1
|
50
|
33
|
|
|
9
|
if( $args && ref $args ne 'HASH' ) { |
126
|
0
|
|
|
|
|
0
|
croak('get_url_list() requires HASH ref arguments.'); |
127
|
|
|
|
|
|
|
} |
128
|
1
|
|
|
|
|
12
|
my $uri = URI->new( $API_uri ); |
129
|
1
|
|
|
|
|
129
|
$uri->query_param( m => 'ul' ); # url list mode. |
130
|
1
|
50
|
33
|
|
|
196
|
$uri->query_param( usid => $args->{usid} ) if $args && $args->{usid}; |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
8
|
my $res = $self->_fetch( $uri ); |
133
|
1
|
50
|
|
|
|
59935097
|
return unless $res; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
return WebService::FC2::SpamAPI::Response->parse_list( $res->content ); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 get_domain_list |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Get registered spam URL list in domain. |
141
|
|
|
|
|
|
|
Returns WebService::FC2::SpamAPI::Response list. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
@res = $api->get_domain_list({ dm => 'example.com' }); # dm is required. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
@res = $api->get_domain_list({ |
146
|
|
|
|
|
|
|
dm => 'example.com', |
147
|
|
|
|
|
|
|
usid => 0000, # grep by userid |
148
|
|
|
|
|
|
|
}); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub get_domain_list { |
153
|
1
|
|
|
1
|
1
|
3824
|
my ( $self, $args ) = @_; |
154
|
|
|
|
|
|
|
|
155
|
1
|
50
|
|
|
|
9
|
if ( ref $args ne 'HASH' ) { |
156
|
0
|
|
|
|
|
0
|
croak('get_domain_list() requires HASH ref arguments.'); |
157
|
|
|
|
|
|
|
} |
158
|
1
|
50
|
|
|
|
6
|
if ( !(defined $args->{dm} ) ) { |
159
|
0
|
|
|
|
|
0
|
croak('get_domain_list() requires dm (domain) arguments.'); |
160
|
|
|
|
|
|
|
} |
161
|
1
|
|
|
|
|
9
|
my $uri = URI->new( $API_uri ); |
162
|
1
|
|
|
|
|
124
|
$uri->query_param( m => 'dl' ); # domain list mode. |
163
|
1
|
|
|
|
|
163
|
$uri->query_param( dm => $args->{dm} ); |
164
|
1
|
50
|
33
|
|
|
194
|
$uri->query_param( usid => $args->{usid} ) if $args && $args->{usid}; |
165
|
|
|
|
|
|
|
|
166
|
1
|
|
|
|
|
7
|
my $res = $self->_fetch( $uri ); |
167
|
1
|
50
|
|
|
|
531789
|
return unless $res; |
168
|
|
|
|
|
|
|
|
169
|
1
|
|
|
|
|
7
|
return WebService::FC2::SpamAPI::Response->parse_list( $res->content ); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub _fetch { |
173
|
4
|
|
|
4
|
|
12
|
my ( $self, $uri ) = @_; |
174
|
|
|
|
|
|
|
|
175
|
4
|
|
|
|
|
14
|
my %options; |
176
|
4
|
50
|
|
|
|
26
|
$options{Cache} = $self->cache if $self->cache; |
177
|
4
|
50
|
33
|
|
|
122
|
$uri = ( ref $uri && $uri->isa('URI') ) ? $uri->as_string : $uri; |
178
|
|
|
|
|
|
|
|
179
|
4
|
|
|
|
|
65
|
return URI::Fetch->fetch( $uri, %options ); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 SEE ALSO |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L, L, http://seo.fc2.com/spam/ |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 AUTHOR |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
FUJIWARA Shunichiro, C<< >> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Copyright 2007 FUJIWARA Shunichiro, all rights reserved. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
195
|
|
|
|
|
|
|
under the same terms as Perl itself. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; # End of WebService::FC2::SpamAPI |