class CAPTCHME::Captchme

Public Class Methods

new(private_key, params, ip_client) click to toggle source
# File lib/captchme.rb, line 8
def initialize(private_key, params, ip_client)
  @private_key = private_key
  @data = "private_key=" +  @private_key + "&challenge_key="+
  params["captchme_challenge_field"] + "&response=" +
  params["captchme_response_field"] + "&user_ip=" + ip_client;
  @headers = {
    "Content-Type" => "application/x-www-form-urlencoded",
    "Content-length" => @data.length.to_s,
    "Connection" => "close"
  }
  @uri = URI("http://api.captchme.net/api/verify")
  @http = Net::HTTP.new(@uri.host, @uri.port)
end

Public Instance Methods

is_valid?() click to toggle source
# File lib/captchme.rb, line 26
def is_valid?
  @response[0] == 'true'
end
request() click to toggle source
# File lib/captchme.rb, line 22
def request
  @response = @http.post(@uri.path, @data, @headers).body.split
end