Net-Akismet-0.05000755 002001 002001 00000000000 11022017462 012507 5ustar00nbnb000000 000000 Net-Akismet-0.05/t000755 002001 002001 00000000000 11022017462 012752 5ustar00nbnb000000 000000 Net-Akismet-0.05/t/Net-Akismet-podcheck.t000644 002001 002001 00000001367 10452026246 017132 0ustar00nbnb000000 000000 # $Id: Net-Akismet-podcheck.t 135 2006-01-27 17:54:46Z roam $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Net-Akismet-coverage.t' use Pod::Checker; use Test; plan tests => 6; my ($c, $res); $c = new Pod::Checker '-warnings' => 1; ok($c); $res = $c->parse_from_file('lib/Net/Akismet.pm', \*STDERR); if ($res == -1) { warn "No POD data found in Net::Akismet\n"; } ok(!$res); ok($c->num_errors() == 0 && $c->num_warnings() == 0); $c = new Pod::Checker '-warnings' => 5; ok($c); $res = $c->parse_from_file('lib/Net/Akismet.pm', \*STDERR); if ($res == -1) { warn "No POD data found in Net::Akismet\n"; } ok(!$res); ok($c->num_errors() == 0 && $c->num_warnings() == 0); Net-Akismet-0.05/t/Net-Akismet.t000644 002001 002001 00000000731 10452026246 015346 0ustar00nbnb000000 000000 # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Net-Akismet.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; BEGIN { use_ok('Net::Akismet') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. Net-Akismet-0.05/t/Net-Akismet-coverage.t000644 002001 002001 00000000530 10452026246 017134 0ustar00nbnb000000 000000 # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Net-Akismet-coverage.t' BEGIN { eval 'use Test::Pod::Coverage tests => 1'; if ($@) { use Test; plan tests => 1; skip('Test::Pod::Coverage not found'); exit(0); } } pod_coverage_ok('Net::Akismet'); Net-Akismet-0.05/META.yml000644 002001 002001 00000000532 11022017462 014037 0ustar00nbnb000000 000000 # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Net-Akismet version: 0.05 version_from: lib/Net/Akismet.pm installdirs: site requires: LWP: 5.09 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 Net-Akismet-0.05/lib000755 002001 002001 00000000000 11022017462 013255 5ustar00nbnb000000 000000 Net-Akismet-0.05/lib/Net000755 002001 002001 00000000000 11022017462 014003 5ustar00nbnb000000 000000 Net-Akismet-0.05/lib/Net/Akismet.pm000644 002001 002001 00000014271 11022017424 016020 0ustar00nbnb000000 000000 package Net::Akismet; =head1 NAME Net::Akismet - Perl interface to Akismet - comment and trackback spam fighter =cut use 5.006; use warnings; use strict; use integer; use LWP::UserAgent; use HTTP::Request::Common; our $VERSION = '0.05'; my $UA_SUFFIX = "Perl-Net-Akismet/$VERSION"; =head1 SYNOPSIS my $akismet = Net::Akismet->new( KEY => 'secret-baba-API-key', URL => 'http://example.blog.net/', ) or die('Key verification failure!'); my $verdict = $akismet->check( USER_IP => '10.10.10.11', COMMENT_USER_AGENT => 'Mozilla/5.0', COMMENT_CONTENT => 'Run, Lola, Run, the spam will catch you!', COMMENT_AUTHOR => 'dosser', COMMENT_AUTHOR_EMAIL => 'dosser@subway.de', REFERRER => 'http://lola.home/', ) or die('Is the server here?'); if ('true' eq $verdict) { print "I found spam. I am a spam-founder!\n"; } =head1 METHODS =over 8 =item B Net::Akismet->new(PARAM => ...); Acceptable parameters: =over 4 =item KEY The API key being verified for use with the API. =item URL The front page or home URL of the instance making the request. For a blog or wiki this would be the front page. =item USER_AGENT If supplied the value is prepended to this module's identification string to become something like: your-killer-app/0.042 Perl-Net-Akismet/0.01 libwww-perl/5.8 Otherwise just Akismet Perl's user agent string will be sent. =item SERVICE_HOST If supplied, the host of the service API. The default is rest.akismet.com =item SERVICE_VERSION If supplied, the API version. The default is 1.1 =back If verification of the key was unsuccessful C returns C. =cut sub new { my $that = shift; my $class = ref $that || $that; my %params = @_; my $self = \%params; $self->{ua} = LWP::UserAgent->new() or return undef; my $key = $self->{KEY} or return undef; my $url = $self->{URL} or return undef; # NOTE: trailing space leaves LWP::UserAgent agent string in place my $agent = "$UA_SUFFIX "; $agent = "$params{USER_AGENT} $agent" if $params{USER_AGENT}; $self->{ua}->agent($agent); $self->{SERVICE_HOST} = $params{SERVICE_HOST} || 'rest.akismet.com'; $self->{SERVICE_VERSION} = $params{SERVICE_VERSION} || '1.1'; bless $self, $class; return $self->_verify_key()? $self : undef; } sub _verify_key { my $self = shift; my $response = $self->{ua}->request( POST "http://$self->{SERVICE_HOST}/$self->{SERVICE_VERSION}/verify-key", [ key => $self->{KEY}, blog => $self->{URL}, ] ); ($response && $response->is_success() && 'valid' eq $response->content()) or return undef; return 1; } =item B $akismet->check(USER_IP => ..., COMMENT_CONTENT => ..., ...) To be or not to be... C is meant to tell you. Give it enough details about the comment and expect C<'true'>, C<'false'> or C as a result. C<'true'> means B, C<'false'> means B, C is returned on errror in submission of the comment. Acceptable comment characteristics: =over 4 =item USER_IP B Represents the IP address of the comment submitter. =item COMMENT_USER_AGENT B User agent string from the comment submitter's request. =item COMMENT_CONTENT Comment text. =item REFERRER HTTP C header. =item PERMALINK Permanent link to the subject of the comment. =item COMMENT_TYPE May be blank, 'comment', 'trackback', 'pingback', or a made up value like 'registration'. =item COMMENT_AUTHOR Name of submitter. =item COMMENT_AUTHOR_EMAIL Submitter e-mail. =item COMMENT_AUTHOR_URL Submitter web page. =back =cut sub check { my $self = shift; $self->_submit('comment-check', {@_}) or return undef; ('true' eq $self->{response} || 'false' eq $self->{response}) or return undef; return $self->{response}; } =item B Reports a certain comment as spam. Accepts the same arguments as C. In case of failed submission returns C, otherwise - a perl-known truth. =cut sub spam { my $self = shift; return $self->_submit('submit-spam', {@_}); } =item B This call is intended for the marking of false positives, things that were incorrectly marked as spam. It takes identical arguments as C and C. In case of failed submission returns C, otherwise - a perl-known truth. =cut sub ham { my $self = shift; return $self->_submit('submit-ham', {@_}); } sub _submit { my $self = shift; my $action = shift || 'comment-check'; my $comment = shift; $comment->{USER_IP} && $comment->{COMMENT_USER_AGENT} || return undef; # accomodate common misspelling $comment->{REFERRER} = $comment->{REFERER} if !$comment->{REFERRER} && $comment->{REFERER}; my $response = $self->{ua}->request( POST "http://$self->{KEY}.$self->{SERVICE_HOST}/$self->{SERVICE_VERSION}/$action", [ blog => $self->{URL}, user_ip => $comment->{USER_IP}, user_agent => $comment->{COMMENT_USER_AGENT}, referrer => $comment->{REFERRER}, permalink => $comment->{PERMALINK}, comment_type => $comment->{COMMENT_TYPE}, comment_author => $comment->{COMMENT_AUTHOR}, comment_author_email => $comment->{COMMENT_AUTHOR_EMAIL}, comment_author_url => $comment->{COMMENT_AUTHOR_URL}, comment_content => $comment->{COMMENT_CONTENT}, ] ); ($response && $response->is_success()) or return undef; $self->{response} = $response->content(); return 1; } 1; =back =head1 NOTES Although almost all comment characteristics are optional, performance can drop dramatically if you exclude certain elements. So please, supply as much comment detail as possible. =head1 SEE ALSO =over 4 =item * http://akismet.com/ =item * http://akismet.com/development/api/ =back =head1 AUTHOR Nikolay Bachiyski Enb@nikolay.bgE =head2 Help, modifications and bugfixes from: =over 4 =item * Peter Pentchev =item * John Belmonte =back =head1 COPYRIGHT AND LICENSE Copyright (C) 2006, 2007, 2008 by Nikolay Bachiyski This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available. $Id: Akismet.pm 38 2008-06-05 17:15:12Z humperdink $ =cut Net-Akismet-0.05/Changes000644 002001 002001 00000001242 11022017424 014056 0ustar00nbnb000000 000000 Revision history for Perl extension Net::Akismet. 0.05 - mention in the docs about the host/version feature 0.04 Thu Jun 5 19:58:41 EEST 2008 - allow service host and version to be changed from the constructor - SYNOPSIS fixes by John Belmonte 0.03 Mon Aug 27 10:28:28 EEST 2007 - proper user agent handling, patch by John Belmonte, rt bug #28939 0.02 Sun Jul 2 23:12:27 2006 - fixed install problems with perl <5.8.4 - some new test added (thanks to Peter Pentchev) 0.01 Wed Jan 11 13:31:42 2006 - original version; created by h2xs 1.23 with options -AX --skip-exporter --use-new-tests -n Net::Akismet $Id: Changes 38 2008-06-05 17:15:12Z humperdink $ Net-Akismet-0.05/MANIFEST000644 002001 002001 00000000310 10452027474 013723 0ustar00nbnb000000 000000 Changes Makefile.PL MANIFEST README t/Net-Akismet.t t/Net-Akismet-podcheck.t t/Net-Akismet-coverage.t lib/Net/Akismet.pm META.yml Module meta-data (added by MakeMaker) Net-Akismet-0.05/Makefile.PL000644 002001 002001 00000001034 10452026322 014537 0ustar00nbnb000000 000000 use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Net::Akismet', VERSION_FROM => 'lib/Net/Akismet.pm', # finds $VERSION PREREQ_PM => { 'LWP' => '5.09', }, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Net/Akismet.pm', # retrieve abstract from module AUTHOR => 'Nikolay Bachiyski ') : ()), ); Net-Akismet-0.05/README000644 002001 002001 00000001635 11022017424 013451 0ustar00nbnb000000 000000 Net-Akismet version 0.05 ======================== Net::Akismet is meant to provide perl interface to the Akismet web service. Akismet is blog comment and trackback spam blocker, free for personal use. More info on http://akismet.com/ The module allows you to either check if an item is spam or report certain comment as spam/false postivie. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: libwww-perl COPYRIGHT AND LICENCE Put the correct copyright and licence information here. Copyright (C) 2006 by Nikolay Bachiyski This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available. $Id: README 38 2008-06-05 17:15:12Z humperdink $