Add your keys
If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.
POST data
setExpectedHostname($_SERVER['SERVER_NAME']) ->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); if ($resp->isSuccess()): // If the response is a success, that's it! ?>Success!
That's it. Everything is working. Go integrate this into your real project.
Something went wrong
Check the error code reference at https://developers.google.com/recaptcha/docs/verify#error-code-reference.
Note: Error code missing-input-response may mean the user just didn't complete the reCAPTCHA.
Submit the form and reCAPTCHA will run automatically.