Net::Akismet(3pm)
π Net::Akismet π
okay bestie, so this is Net::Akismet β a Perl interface to Akismet, aka the comment and trackback spam fighter. it's a Perl module, so it lives in section 3pm of the manual (User Contributed Perl Documentation, to be exact), and it's genuinely SO useful if you run anything where strangers can leave comments. spam is the enemy and this is the sword. π‘οΈβ¨
πΈ SYNOPSIS πΈ
here's the whole vibe, look:
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";
}
like the or die(...) calls? not me being dramatic about error handling, but fr fr, that's just what good code does. π
β¨ METHODS β¨
π new()
Net::Akismet->new(PARAM => ...);
these are the parameters it'll accept, no more no less:
KEYβ the API key that's being verified for use with the API. πURLβ the front page or home URL of the instance making the request. for a blog or a wiki, this would be the front page.USER_AGENTβ if you supply it, the value gets prepended to this module's identification string, which makes it turn into something like:
your-killer-app/0.042 Perl-Net-Akismet/0.01 libwww-perl/5.8
otherwise, just Akismet Perl's user agent string gets sent. simple as that.
SERVICE_HOSTβ if supplied, it's the host of the service API. the default isrest.akismet.comSERVICE_VERSIONβ if supplied, it's the API version. the default is1.1
β οΈ heads up bestie: if the verification of the key was unsuccessful,new()returnsundef. so like, check for that, okay? don't let it slide. π«Ά
π¦ check()
$akismet->check(USER_IP => ..., COMMENT_CONTENT => ..., ...)
to be or not to be... check is literally there to tell you which one it is. π give it enough details about the comment and it'll hand you back 'true', 'false', or undef.
'true'means spam'false'means not spamundefgets returned when there's an error in the submission of the comment
and here are the acceptable comment characteristics β read them, they matter:
USER_IPβ Required. represents the IP address of the comment submitter.COMMENT_USER_AGENTβ Required. the user agent string from the comment submitter's request.COMMENT_CONTENTβ the comment text.REFERRERβ the HTTP "Referer" header.PERMALINKβ a permanent link to the subject of the comment.COMMENT_TYPEβ may be blank,'comment','trackback','pingback', or a made up value like'registration'. yes really, go feral, make one up. πCOMMENT_AUTHORβ name of the submitter.COMMENT_AUTHOR_EMAILβ submitter e-mail.COMMENT_AUTHOR_URLβ submitter's web page.
π spam()
reports a certain comment as spam. it accepts the same arguments as check().
in the case of a failed submission it returns undef; otherwise you get a perl-known truth. periodt.
π ham()
this call is meant for marking false positives β the things that were incorrectly marked as spam, bless their hearts. it takes identical arguments as check() and spam().
in the case of a failed submission it returns undef; otherwise, again, a perl-known truth. π
π NOTES π
so technically almost all of the comment characteristics are optional, BUT β and this is the important part β performance can drop dramatically if you exclude certain elements. so please, girlypop, supply as much comment detail as you possibly can. more info = better vibes. πΈ
π SEE ALSO π
π AUTHOR π
Nikolay Bachiyski <nb@nikolay.bg>
π Help, modifications and bugfixes from:
- Peter Pentchev
- John Belmonte
π 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 $
okay that's the whole page bestie, mwah π this was perl v5.36.0, dated 2022-10-13, and it's the Net::Akismet(3pm) page from User Contributed Perl Documentation. go forth and obliterate some spam. slay. π
β¨π¦
π¦ where this page comes from
- ubuntu noble: libnet-akismet-perl 0.05-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-akismet-perl 0.05-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-akismet-perl 0.05-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms