PHP code example of neutron / recaptcha

1. Go to this page and download the library: Download neutron/recaptcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

neutron / recaptcha example snippets


use Neutron\ReCaptcha\ReCaptcha;
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
use Silex\Application;

$app = new Application();
$app->register(new ReCaptchaServiceProvider(), array(
    'recaptcha.public-key'  => 'fdspoksqdpofdkpopgqpdskofpkosd',
    'recaptcha.private-key' => 'lsdmkzfqposfomkcqdsofmsdkfkqsdmfmqsdm',
));

// $captcha is an instance of Neutron\ReCaptcha\Response
$captcha = $app['recaptcha']->bind($app['request']);

if ($captcha->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :( " . $captcha->getError();
}

use Neutron\ReCaptcha\ReCaptcha;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);

use Neutron\ReCaptcha\ReCaptcha;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);
$response = $recaptcha->checkAnswer($_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);

if ($response->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :(";
}

use Neutron\ReCaptcha\ReCaptcha;
use Symfony\Component\HttpFoundation\Request;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);
$response = $recaptcha->bind(Request::createFromGlobals());

if ($response->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :( " . $response->getError();
}