local response = http.request({url='http://www.google.com/recaptcha/api/verify',
method='post',
data={
privatekey = '<YOUR PRIVATE KEY HERE>',
remoteip = request.remote_addr,
challenge = request.form.challenge,
response = request.form.response
}}).content
local firstline = response:match('[^\n]*')
if firstline == 'true' then
-- CAPTCHA passed. Do things here.
return { success=true }
else
-- CAPTCHA failed.
return { success=false }
end
$('#recaptchaButton').click(function (e) {
e.preventDefault();
$.post('https://examples.webscript.io/recaptcha',
{ challenge: Recaptcha.get_challenge(), response:Recaptcha.get_response() },
function (data) {
if (data.success) {
alert("Captcha completed successfully!");
loadCaptcha();
} else {
alert("Captcha failed.");
}
});
});