Mollom Ruby Gem
Mollom, an Openminds client, recently released a new web service created by Drupal’s founder Dries Buytaert and Benjamin Schrauwen. In it’s own words, Mollom is a web service that helps you identify content quality and, more importantly, helps you stop comment and contact form spam. Other than that, it also provides a way to let users enter a CAPTCHA if their content has been marked as spam. That way a real person will always be able to enter content.
The mollom site currently provides a module for Drupal, and a Java Class, but no Ruby version yet, and there we come in. We created a gem to interface with Mollom. It provides the basic API functionality, and follows the API-docs as much as possible.
To use mollom, you need an API-key, which you can get at http://www.mollom.com.
Installing the gem is as easy as:
gem install mollom
Or you can also get the latest development version from GitHub:
git clone git://github.com/DefV/ruby-mollom.git
You can use the code like in the following example:
require 'rubygems'
require 'mollom'
m = Mollom.new(:private_key => 'your_private_key',
:public_key => 'your_public_key')
content = m.check_content(
:post_title => 'Mollem is an open API',
:post_body => "Lorem ipsum ...",
:author_name => 'Jan De Poorter',
:author_url => 'http://www.openminds.be'
)
if content.unsure? or content.spam?
- Maybe Spam? Show user a CAPTCHA!
puts m.image_captcha(:session_id => content.session_id)[“url”]
puts m.check_captcha(:session_id => content.session_id,
:solution => STDIN.gets.chomp)
else
puts “The post is perfect! No spam!”
end
The complete documentation for this library can be found at http://mollom.rubyforge.org/ .
And for all the Ruby on Rails users: a Rails plugin is on its way!