Subject: | Support user-supplied Akismet REST endpoints (e.g. TypePad AntiSpam) |
Hi,
I'd like to see a way for the user to override the default REST endpoint
used in the plugin (rest.akismet.com) to be able to use
Akismet-compatible endpoints (like TypePad's new AntiSpam service.)
Attached is a patch to enable this feature by introducing a new
(optional) parameter for new(), SERVICE_HOST, that receives the
alternate endpoint (e.g. 'api.antispam.typepad.com') or defaults to the
official Akismet endpoint.
Cheers,
Zakame
Subject: | 0001-Add-support-for-user-supplied-Akismet-services.patch |
From 84b4d956aea419742761c6041d339a38593ebe72 Mon Sep 17 00:00:00 2001
From: Zak B. Elep <zakame@spunge.org>
Date: Wed, 4 Jun 2008 16:13:26 +0800
Subject: [PATCH] Add support for user-supplied Akismet services
Allow the user to be able to supply her own REST endpoint to an
Akismet-compatible service, like TypePad AntiSpam, and use that
instead of the default (official) Akismet endpoint.
Signed-off-by: Zak B. Elep <zakame@cpan.org>
---
lib/Net/Akismet.pm | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/Net/Akismet.pm b/lib/Net/Akismet.pm
index 5f664db..4b8d5ae 100644
--- a/lib/Net/Akismet.pm
+++ b/lib/Net/Akismet.pm
@@ -20,11 +20,19 @@ my $UA_SUFFIX = "Perl-Net-Akismet/$VERSION";
=head1 SYNOPSIS
+ # use the official Akismet service
my $akismet = Net::Akismet->new(
KEY => 'secret-baba-API-key',
URL => 'http://example.blog.net/',
) or die('Key verification failure!');
+ # or use an Akismet-compatible service like TypePad AntiSpam
+ my $akismet = Net::Akismet->new(
+ KEY => 'secret-fifi-API-key',
+ URL => 'http://anotherex.blog.org',
+ SERVICE_HOST => 'api.antispam.typepad.com',
+ ) or die('Key verification failure!');
+
my $verdict = $akismet->check(
USER_IP => '10.10.10.11',
USER_AGENT => 'Mozilla/5.0',
@@ -85,6 +93,7 @@ sub new {
my $key = $self->{KEY} or return undef;
my $url = $self->{URL} or return undef;
+ my $svc_host = $self->{SERVICE_HOST} || 'rest.akismet.com';
# NOTE: trailing space leaves LWP::UserAgent agent string in place
my $agent = "$UA_SUFFIX ";
@@ -102,7 +111,7 @@ sub _verify_key {
my $response = $self->{ua}->request(
- POST 'http://rest.akismet.com/1.1/verify-key',
+ POST "http://$svc_host/1.1/verify-key",
[
key => $self->{KEY},
blog => $self->{URL},
@@ -217,7 +226,7 @@ sub _submit {
$comment->{USER_IP} && $comment->{COMMENT_USER_AGENT} || return undef;
my $response = $self->{ua}->request(
- POST "http://$self->{KEY}.rest.akismet.com/1.1/$action",
+ POST "http://$self->{KEY}.$svc_host/1.1/$action",
[
blog => $self->{URL},
user_ip => $comment->{USER_IP},
@@ -269,6 +278,8 @@ Nikolay Bachiyski E<lt>nbachiyski@developer.bgE<gt>
=item * John Belmonte
+=item * Zak Elep
+
=back
=head1 COPYRIGHT AND LICENSE
--
1.5.4.3