Skip to main content
cuerpo editado
Origen Enlace
Jorgesys
  • 111.1k
  • 14
  • 55
  • 134

Me saliosalió, haciendo lo siguiente, pero no sé si es una buena practicapráctica:

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

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

Me salió, haciendo lo siguiente, pero no sé si es una buena práctica:

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

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

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

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
Origen Enlace
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