Can anybody please clear up for me what the final page of the recaptcha documentation is saying, I find it exceptionally obtuse.
Here's the documentation I fail to understand:
Verifying the user's response
This page explains how to verify a user's response to a reCAPTCHA challenge from your application's backend. When a reCAPTCHA is solved by end user, a new field (g-recaptcha-response) will be populated in HTML. You can verify the user’s response in one of three ways:
g-recaptcha-response POST parameter when the user submits the form on your site. grecaptcha.getResponse(opt_widget_id) after the user completes the CAPTCHA challenge. As a string argument to your callback function if data-callback is specified in either the g-recaptcha tag attribute or the callback parameter in the grecaptcha.render method
API Request
How exactly do I 'verify'?
It says there are three ways I can "verify the user's response", so let's take the first one: there is now a POST parameter in the submitted form called g-recaptcha-response with some gobbledygook content. My question is: now what? Do I just check that it's not null?
Or do I then to send it to google using the API request mentioned below and then check their response? That might make sense, but it would be nice if the docs spelled it out, instead it just says 'API Request'. It would also be nice if they spelled it out that the response_string is (presumably) the contents of the g-recaptcha-response parameter.
Obviously my expensive education wasn't expensive enough, please could someone just confirm for my peace of mind that I should be doing the API Request.
This brings me to the second problem: you can test that the recaptcha widget works ok from local machine, but you can't test the 'API Request' - I get a cross-site error
XMLHttpRequest cannot load https://www.google.com/recaptcha/api/siteverify. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
http://localhost
' is therefore not allowed access.
Anybody know a way of getting around this so that you can do tests?