You can find full documentation about Google reCAPTCHA API v2 here.
You can install this package with Composer. Add next lines to your composer.json file:
{
"require": {
"dario_swain/re-captcha-library": "1.0.*"
}
}
Use ReCaptcha class for sending request to google API:
<?php
$privateKey = 'PRIVATE_KEY'; //You Google API private key
$clientIp = $_SERVER['REMOTE_ADDR']; //Client IP Address
$gReCaptchaResponse = $_POST['g-recaptcha-response']; //Google reCAPTCHA response
$reCaptcha = new ReCaptcha($privateKey, $clientIp, $gReCaptchaResponse);
$response = $reCaptcha->buildRequest()->send();
if($response->isSuccess())
{
//Submit form ...
}
Copyright (c) 2015 Ilya Pokamestov dario_swain@yahoo.com.