2014-01-21 3 views

답변

6

플러그인없이 reCaptcha를 사용하는 것은 그렇게 어렵지 않습니다. here for how to display reCaptcha without pluginshere for how to verify the user's answer을 참조하십시오. API는 매우 간단합니다. 사용자가 captcha를 해결하면 recaptcha_challenge_fieldrecaptcha_response_field의 두 매개 변수가 제출됩니다. 이를 사용하여 서버에서 확인 API를 호출하고 솔루션이 정상인지 확인할 수 있습니다. 예 :

require 'net/http' 
require 'json' 

post '/check_captcha' do 
    res = Net::HTTP.post_form(
    URI.parse('http://www.google.com/recaptcha/api/verify'), 
    { 
     'privatekey' => 'Your private key', 
     'remoteip' => request.ip, 
     'challenge' => params[:recaptcha_challenge_field], 
     'response' => params[:recaptcha_response_field] 
    } 
) 

    success, error_key = res.body.lines.map(&:chomp) 

    if success == 'true' 
    # solved the captcha 
    else 
    # did not solve the captcha 
    end 
end 
+0

감사합니다. @ p11y! –