Elliot Haughin

I'm a freelance web developer.
I build clever, engaging, ass-kicking,
web applications. You want 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.

  7. Matthew says:

    I love this library. Just a quick question about this and typepad antispam though.

    I want to use this with typepads antispam which i’ve been hearing good things about. Looking on Typepads site it says all you need to do is change one item and it will work with any plugin made for Akismet.

    change: rest.akismet.com to api.antispam.typepad.com

    You’ve done a great job with this by giving us var $akismet_server = ‘rest.akismet.com’;

    Do you think that this is all i would need to change to get it working with typepad as there documentation isn’t great.

    Cheers for all your hard work.

  8. Himawans says:

    waww,,krenn,,thanks you,,
    salam kenal,,,

  9. Peter Hough says:

    I’ve just come across a little typo: line 159: $this->_get_querystring() should be $this->_get_query_string()

    It seems to be working if you alter that, thanks for the script!

    Pete

  10. Isern Palaus says:

    That’s true, Peter Hough. Needs to be revised, changed on my file :-)

    Thank you too!

  11. Aziz Light says:

    Nice library.
    There is one thing I don’t understand though: what is log_error()? Is it an old version of CodeIgniter’s log_message?

    I probably misuderstand how the class works, but seeing how you use it, isn’t the comment submitted all the time since you post it at the end of the first if statement (unless log_error does a redirect or something similar, which brings me back to the first question, what is log_error?).

  12. Serhat says:

    I don’t know why but this doesn’t work for me. Is this old or something?

Leave a Comment

© Copyright 2010 Elliot Haughin