Class: Merb::Threshold::RecaptchaClient
- Inherits:
-
Object
- Object
- Merb::Threshold::RecaptchaClient
- Defined in:
- lib/merb_threshold/recaptcha_client.rb
Constant Summary collapse
- API_SERVER =
"http://api.recaptcha.net"- API_SSL_SERVER =
"https://api-secure.recaptcha.net"- API_VERIFY_SERVER =
"http://api-verify.recaptcha.net"
Class Method Summary collapse
- .private_key ⇒ Object
- .private_key=(key) ⇒ Object
- .public_key ⇒ Object
- .public_key=(key) ⇒ Object
-
.solve(ip, challenge, response) ⇒ Array[Boolean,String]
Attempt to solve the captcha.
Class Method Details
.private_key ⇒ Object
16 17 18 |
# File 'lib/merb_threshold/recaptcha_client.rb', line 16 def self.private_key @@private_key end |
.private_key=(key) ⇒ Object
19 20 21 |
# File 'lib/merb_threshold/recaptcha_client.rb', line 19 def self.private_key=(key) @@private_key = key end |
.public_key ⇒ Object
10 11 12 |
# File 'lib/merb_threshold/recaptcha_client.rb', line 10 def self.public_key @@public_key end |
.public_key=(key) ⇒ Object
13 14 15 |
# File 'lib/merb_threshold/recaptcha_client.rb', line 13 def self.public_key=(key) @@public_key = key end |
.solve(ip, challenge, response) ⇒ Array[Boolean,String]
Attempt to solve the captcha
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/merb_threshold/recaptcha_client.rb', line 32 def self.solve(ip,challenge,response) response = Net::HTTP.post_form(URI.parse(API_VERIFY_SERVER + '/verify'),{ :privatekey => @@private_key, :remoteip => ip, #request.remote_ip, :challenge => challenge, #params[:recaptcha_challenge_field], :response => response #params[:recaptcha_response_field] }) answer, error = response.body.split.map { |s| s.chomp } [ !!(answer=='true'), error ] end |