| Class | Mollom |
| In: |
lib/mollom.rb
|
| Parent: | Object |
| API_VERSION | = | '1.0' |
| private_key | [RW] | |
| public_key | [RW] |
Creates a new Mollom object. Takes private_key and public_key as keys.
Mollom.new(:private_key => 'qopzalnzanzajlazjna', :public_key => 'aksakzaddazidzaodjaz') # => #<Mollom:0x5b6454 @public_key="aksakzaddazidzaodjaz", @private_key="qopzalnzanzajlazjna">
# File lib/mollom.rb, line 23
23: def initialize options = {}
24: @private_key = options[:private_key]
25: @public_key = options[:public_key]
26: end
Requests an Audio captcha from Mollom. It takes the optional session_id and author_ip keys, if you allready have a session. It returns a hash with the URL where the captcha can be found, and the session_id, to keep track of the current session (Needed later in Mollom#check_captcha)
captcha = mollom.audio_captcha :author_ip => '172.16.0.2', :session_id => 'a9616e6b4cd6a81ecdd509fa624d895d' captcha['url'] # => http://xmlrpc1.mollom.com:80/a9616e6b4cd6a81ecdd509fa624d895d.mp3 captcha['session_id'] # => a9616e6b4cd6a81ecdd509fa624d895d
# File lib/mollom.rb, line 69
69: def audio_captcha info = {}
70: return send_command('mollom.getAudioCaptcha', info)
71: end
Checks the content whether it is spam, ham (not spam), or undecided, and gives a quality assessment of the content. Possible content keys are:
session_id # => If you allready have a session_id post_title # => The title post_body # => The main content of the post. author_name # => The name of the post author author_url # => The url the author enters author_mail # => The author's email address author_ip # => The author's IP address author_openid # => The author's OpenID author_id # => The author's ID
Only the post_body key is required, all other keys are optional. This function returns a ContentResponse object.
response = mollom.check_content :post_title => 'Mollom rules!',
:post_body => 'I think that mollom is so cool!',
:author_name => 'Jan De Poorter',
:author_url => 'http://www.openminds.be'
response.spam? # => false
response.ham? # => true
# File lib/mollom.rb, line 49
49: def check_content content = {}
50: return ContentResponse.new(send_command('mollom.checkContent', content))
51: end
Requests an Image captcha from Mollom. It takes the optional session_id and author_ip keys, if you allready have a session. It returns a hash with the URL where the captcha can be found, and the session_id, to keep track of the current session (Needed later in Mollom#check_captcha)
captcha = mollom.image_captcha :author_ip => '172.16.0.1' captcha['url'] # => http://xmlrpc1.mollom.com:80/a9616e6b4cd6a81ecdd509fa624d895d.png captcha['session_id'] # => a9616e6b4cd6a81ecdd509fa624d895d
# File lib/mollom.rb, line 59
59: def image_captcha info = {}
60: return send_command('mollom.getImageCaptcha', info)
61: end
Standard check to see if your public/private keypair are recognized. Takes no options
# File lib/mollom.rb, line 85
85: def key_ok?
86: return send_command('mollom.verifyKey')
87: end
Send feedback to Mollom about a certain content. Required keys are session_id and feedback.
Feedback can be any of
spam profanity low-quality unwanted mollow.send_feedback :session_id => 'a9616e6b4cd6a81ecdd509fa624d895d', :feedback => 'unwanted'
# File lib/mollom.rb, line 114
114: def send_feedback feedback = {}
115: return send_command('mollom.sendFeedback', feedback)
116: end
Gets some statistics from Mollom about your site.
The type has to be passed. Possible types:
total_days total_accepted total_rejected yesterday_accepted yesterday_rejected today_accepted today_rejected mollom.statistics :type => 'total_accepted' # => 123
# File lib/mollom.rb, line 101
101: def statistics options = {}
102: return send_command('mollom.getStatistics', options)
103: end
Checks with mollom if the given captcha (by the user) is correct. Takes session_id and solution keys. Both keys are required. Returns true if the captcha is valid, false if it is incorrect
captcha = mollom.image_captcha :author_ip => '172.16.0.1' # show to user... input from user return = mollom.valid_captcha? :session_id => captcha['session_id'], :solution => 'abcDe9' return # => true
# File lib/mollom.rb, line 80
80: def valid_captcha? info = {}
81: return send_command('mollom.checkCaptcha', info)
82: end