Skip Menu |

This queue is for tickets about the Net-Akismet CPAN distribution.

Report information
The Basics
Id: 36427
Status: resolved
Priority: 0/
Queue: Net-Akismet

People
Owner: Nobody in particular
Requestors: zakame [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



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
From: nbachiyski [...] developer.bg
On Wed Jun 04 04:21:20 2008, ZAKAME wrote: Show quoted text
> 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. >
I added SERVICE_HOST and SERVICE_VERSION arguments to the constructor, but left out the example. You can see the change in 0.05. I added you in the credits in the Changes file, but I forgot to mention you in the perldoc. You will appear there in the next version. Happy hacking, Nikolay.
Fixed in 0.05
Subject: Re: [rt.cpan.org #36427] Support user-supplied Akismet REST endpoints (e.g. TypePad AntiSpam)
Date: Fri, 6 Jun 2008 13:25:43 +0800
To: bug-Net-Akismet [...] rt.cpan.org
From: "Zak B. Elep" <zakame [...] cpan.org>
On Fri, Jun 6, 2008 at 3:02 AM, Nikolay Bachiyski via RT <bug-Net-Akismet@rt.cpan.org> wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=36427 > > I added SERVICE_HOST and SERVICE_VERSION arguments to the constructor, > but left out the example.
Cool! Yeah having the SERVICE_VERSION user-suppliable it a good thing too. I've no problems with my example left out. :D Show quoted text
> I added you in the credits in the Changes file, but I forgot to mention > you in the perldoc. You will appear there in the next version.
No problems with that either! Thanks for fixing this! Cheers, Zakame -- Zak B. Elep || http://zakame.spunge.org zakame@ubuntu.com || zakame@spunge.org || zakame@mor.ph 1486 7957 454D E529 E4F1 F75E 5787 B1FD FA53 851D