I'll go through the steps, just for clarity:
2. Place the script on your page, as close to the top as possible:
3. Place the widget on your page, within your form tags:
a. <div class="g-recaptcha" data-sitekey="your_site_key"></div>
4. On your post-back event, in other words, the code that is executed when the user clicks the submit button, you need to get the response from the widget
a. Sample: var response = Request.Form["g-Recaptcha-Response"];
5. Call to google to see if the user passed the test, note this is .NET C# code:
a.
string secret = "Your_Private/Secret_Key";
var client = new WebClient();
var reply =
client.DownloadString(
secret, response));
CaptchaResponse captchaResponse = JsonConvert.DeserializeObject<CaptchaResponse>(reply);
//when response is false check for the error message
if (!captchaResponse.Success)
{ // this means failed }
else
{ // this means they passed, let them continue }
The "CaptchaResponse" class above is simply a class I created that has two properties:
public class CaptchaResponse
{
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("error-codes")]
public List<string> ErrorCodes { get; set; }
}
You can deserialize the response into anything you want. The reCAPTCHA is not going to stop submission automatically, as that would be way to intrusive. What if a developer wants to do something when they fail? Maybe you want to send an electric shock to their chair... :-)
Here is an example return from the siteverify call:
My object only grabs the success and an error collection. As you can see, there are a few more properties that could be returned that I don't care about.
I hope this helps.
Thanks, Jack