Skip to main content
1 de 3
matiasmasca
  • 555
  • 5
  • 17

Me salio, haciendo lo siguiente, pero no sé si es una buena practica:

    require 'uri'
    require 'net/http'
    require 'openssl'
   
    recaptcha_url = "https://www.google.com/recaptcha/api/siteverify"
    remoteip = request.remote_ip
    uri = URI(recaptcha_url)
    options = { 
      :secret => ENV["SECRET_KEY_CAPTCHA"], 
      :remoteip => request.env["REMOTE_ADDR"], 
      :response => user_response 
    }
    response = Net::HTTP.post_form(URI.parse(recaptcha_url), options)
    puts("Body: #{response.body}")

    #then parse the json response in the above 'response' variable and check whether
    #the API returns a success or failure and return true or false depending on it
    #logger.info "------status ==> #{response.body}"
    hash = JSON.parse(response.body)
    hash["success"] == true ? true : false
matiasmasca
  • 555
  • 5
  • 17