PHP code example of cryental / wowe-recaptcha

1. Go to this page and download the library: Download cryental/wowe-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/ */

    

cryental / wowe-recaptcha example snippets



use \Wowe\Recaptcha\Recaptcha;

$recaptcha = new Recaptcha('secret', 'siteKey');

// index.php
captcha\Recaptcha;
use \Wowe\Recaptcha\Adapters\TwigExtension;

$recaptcha = new Recaptcha('secret', 'siteKey');
$loader = new Twig_Loader_Filesystem(__DIR__ . '/views');
$twig = new Twig_Environment($loader);
$twig->addExtension(new TwigExtension($recaptcha)));
echo $twig->render('index.html');

// views/index.html
<!doctype html>
<html>
    <head>
        {{ recaptchaScript() }}
    </head>
    <body>
        <form method="POST">
            {{ recaptchaWidget() }}
            <input type="submit" />
        </form>
    </body>
</html>


use \Slim\Slim;
use \Wowe\Recaptcha\Adapters\SlimManager;

$app = new Slim([
    'recaptcha' => [
        'secret' => 'secret',
        'siteKey' => 'siteKey'
    ]
]);

SlimManager::register();

$app->get('/', function () use ($app) {
    return $app->render('index.html');
});

$app->post('/', function () use ($app) {
    $recaptchaResponse = $app->request->post('g-recaptcha-response');
    var_dump($app->recaptcha->verify($recaptchaResponse), $app->recaptcha->errors());
});

$app->run();