Elliot Haughin

I'm a freelance web developer.
I build clever, engaging, ass-kicking,
web applications. You want me?

email me, tweet me, skype me

Akismet is a remotely hosted spam-busting web service.
If you have a CodeIgniter application that accepts comments from users, Akismet can help you filter out the ’spam’ comments and keep the ‘real’ comments.

Akismet Logo

We can’t stand spam.

Who can? You have better things to do with your life than deal with the underbelly of the internet. Automattic Kismet (Akismet for short) is a collaborative effort to make comment and trackback spam a non-issue and restore innocence to blogging, so you never have to worry about spam again.

To use the library, you’ll need to get an Akismet API Key

Download the library and put it in your application/libraries/ directory, then place code like this in your controller:

$this->load->library('akismet');
 
$comment = array(
'author'	=> $this->input->post('name'),
'email'		=> $this->input->post('email'),
'website'	=> $this->input->post('website'),
'body'		=> $this->input->post('comment')
);
 
$config = array(
'blog_url' => 'http://www.yoursite.com/',
'api_key' => 'yourapikeyhere',
'comment' => $comment
);
 
$this->akismet->init($config);
 
if ( $this->akismet->errors_exist() )
{				
	if ( $this->akismet->is_error('AKISMET_INVALID_KEY') )
	{
	log_error('AKISMET :: Theres a problem with the api key');
	}
	elseif ( $this->akismet->is_error('AKISMET_RESPONSE_FAILED') )
	{
	log_error('AKISMET :: Looks like the servers not responding');
	}
	elseif ( $this->akismet->is_error('AKISMET_SERVER_NOT_FOUND') )
	{
	log_error('AKISMET :: Wheres the server gone?');
	}
 
	// If the server is down, we have to post the comment :(
	$this->_post_comment($comment);
	$this->load->view('thankyou');
}
else
{
	if ( $this->akismet->is_spam() )
	{
		$this->load->view('spam');
	}
	else
	{
		$this->_post_comment($comment);
		$this->load->view('thankyou');
	}
}

Download Akismet CodeIgniter Library

Version: 1.0

Sponsored Links

Comments

  1. [...] For more details and to download the library, take a look at the Akismet CodeIgniter library’s. [...]

  2. [...] Elliot Haughin | Akismet CodeIgniter Library Akismet is a remotely hosted spam-busting web service. If you have a CodeIgniter application that accepts comments from users, Akismet can help you filter out the ’spam’ comments and keep the ‘real’ comments. (tags: spam akismet codeigniter library elliothaughin) [...]

  3. [...] and via some ready made libraries it is very easy to use from outside Wordpress as well. I am using Elliot Haughin’s CodeIgniter Library, but there are also libraries for PHP, .NET, Ruby on Rails, Drupal etc etc. All you need to do is [...]

  4. [...] J’étais donc occupé à développer un petit système de commentaire pour un projet, et la question du spam est bien entendue venue me titiller les neurones. La façon la plus simple de traiter un problème étant parfois de demander son avis à Google, j’ai trouvé la librairie Akismet pour CodeIgniter. [...]

  5. [...] There is a new Code Igniter library for working with Akismet built by Elliot Haughin. [...]

  6. Will says:

    Dude, Thanks. I’ve been looking for a bunch of Code Igniter Libraries and helpers. Good luck.

Leave a Comment

© Copyright 2009 Elliot Haughin