Now with TypePad support!
Akismetor now supports the free TypePad API in addition to Akismet.
To switch to TypePad, add
:provider => :typepad
to your attributes hash (and don't forget to set your API key to your TypePad key).
If you wish to continue using Akismet, you need do nothing.
This version includes rSpec tests and a method to verify the Akismet key.
This plugin was originally created by Ryan Bates (Railscasts episode 65), being forked from svn.railscasts.com/public/plugins/akismetor
This plugin provides the Akismet class which you can use to communicate with Akismet. Akismet [akismet.com/] is a collaborative spam filtering service.
You can use the class Akismet and its methods, wherever you want inside your Rails application.
./script/plugin install git://github.com/levycarneiro/akismetor
# submits key to Akismet, and returns a string with “valid” or “invalid”. Akismetor.valid_key?(attributes)
# submits comment to Akismet, and returns true if the comment is spam, and false in case it's not. Akismetor.spam?(attributes)
# submits hash as spam to Akismet. Returns a message string. Akismetor.submit_spam(attributes)
# submits hash as ham to Akismet. Returns a message string. Akismetor.submit_ham(attributes)
Let's see a real usage:
:key => '123456789', :blog => 'http://www.my-site.com', :user_ip => '184.108.40.206', :user_agent => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:220.127.116.11) Gecko/2008092414 Firefox/3.0.3', :referrer => 'http://www.another-site.com', :permalink => 'http://www.my-site.com/posts/2', :comment_type => 'comment', :comment_author => 'John Doe', :comment_author_email => '[email protected]', :comment_author_url => 'http://www.doe.com', :comment_content => 'I beg to differ....'
check = Akismetor.spam?(comment_attributes) puts “Is this spam? #checkcheck.to_s.”
The Akismet API
Akismet API Documentation Version 1.1 is at akismet.com/development/api/
The front page or home URL of the instance making the request. For a blog or wiki this would be the front page. Note: Must be a full URI, including http://.
IP address of the comment submitter.
User agent information.
referrer (note spelling)
The content of the HTTP_REFERER header should be sent here.
The permanent location of the entry the comment was submitted to.
May be blank, comment, trackback, pingback, or a made up value like "registration".
Submitted name with the comment
Submitted email address
The content that was submitted.
Other server enviroment variables
In PHP there is an array of enviroment variables called $_SERVER which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.
This call returns either “true” or “false” as the body content. True means that the comment is spam and false means that it isn't spam. If you are having trouble triggering you can send “viagra-test-123” as the author and it will trigger a true response, always.