Module: ActsAsRecaptcha::Validator

Defined in:
lib/acts_as_recaptcha/validator.rb

Class Method Summary collapse

Class Method Details

.validate_recaptcha(challenge, response, remoteip, private_key = ENV['RECAPTCHA_PRIVATE_KEY']) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/acts_as_recaptcha/validator.rb', line 6

def self.validate_recaptcha(challenge, response, remoteip, private_key = ENV['RECAPTCHA_PRIVATE_KEY'] )
  uri = URI.parse("http://www.google.com/recaptcha/api/verify")
  params = {
    :privatekey => private_key,
    :challenge => challenge,
    :response => response,
    :remoteip => remoteip
  }

  Net::HTTP.post_form(uri, params).body.split("\n")
end