Integrate Akismet anti-spam service in PHP Scripts
Jon Moffet
Everybody knows, spam is an annoying thing in the internet. Especially when you create a Contact Form or a Guestbook only to have it filled with junk messages.
Luckily the folks at Automattic have created Akismet as a measures to combat web spams, and best of all it can be integrated right inside your own customized PHP scripts.
First of all, you need to download Akismet PHP4 Class library (and it works with PHP5 too!)
Then get the Wordpress API key from Wordpress.com, simply sign up for an account there, and the API key can be obtained from "My Account" link at the top right when you log in.
Then include akismet.php class file in your php file that does form processing.
-
require('akismet.class.php');
-
-
$wpkey = '**YOUR WORDPRESS KEY***';
-
-
'author' => $comment_author,
-
'email' => $comment_author_email,
-
'website' => $comment_author_website,
-
'body' => $comment,
-
'permalink' => $comment_guestbook_url,
-
'user_ip' => $comment_author_ip,
-
'user_agent' => $comment_author_user_agent,
-
);
-
-
// instantiate an instance of the class
-
$akismet = new Akismet('http://fakapster.com/', $wpkey, $comment);
-
-
-
if($akismet->isSpam()){
-
// store the comment but mark it as spam (in case of a mis-diagnosis)
-
//display a warning
-
-
-
-
-
} else {
-
//this comment is not a spam
-
-
//insert comment into database code
-
-
}
Your guestbook (or online form) should be fairly resistant to spam attacks if you implement anti-spam measures using this method.
Tags: akismet, spam karma, php, anti spam, antispam, spam, spam comments, spams, phpclass
Posted in Uncategorized |








April 10th, 2007 at 4:46 pm
[...] is easy to be included in your own made php scripts as an anti spam solution. Please refer to Integrate Akismet anti-spam service in PHP Scripts, for a brief guide to do [...]
May 9th, 2007 at 6:24 pm
[...] previously previously featured here and here . I’ve improved the contact form example to include Akismet spam protection in order to make it more resistant to spam [...]
June 17th, 2007 at 11:22 pm
wZGYsk bhsdrjkvbfjksbhfsvkbdhfkv
July 1st, 2007 at 5:12 am
Test myfunction comment
August 9th, 2007 at 2:36 pm
Just to add a note that akismet is free under certain conditions and not under others so check their website before you go an implement this one
August 9th, 2007 at 8:58 pm
yes, true. there are no such thing as free lunch. In this case, you (or your clients) might have to pay akismet service if it met with certain conditions
September 3rd, 2007 at 12:26 pm
just have to lately. anything say don’t I ,