PHP code example of zhylon / captcha-laravel

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

    

zhylon / captcha-laravel example snippets


use Zhylon\CaptchaLaravel\Facades\Captcha;

$result = Captcha::verify($request->input('captcha_token'));

if (! $result->success) {
    // $result->reason is one of: invalid_token, config_error, network_error
    // $result->message contains a human-readable explanation
    abort(403, $result->message);
}

use Zhylon\CaptchaLaravel\Facades\CaptchaProxy;

Route::get('pow/challenge', function () {
    $response = CaptchaProxy::challenge(['sitekey' => request()->get('sitekey')]);

    return response()->json($response->body, $response->status);
});

Route::post('pow/verify', function () {
    $response = CaptchaProxy::verify(request()->only(['nonce', 'solve_ms', 'token']));

    return response()->json($response->body, $response->status);
});
bash
php artisan vendor:publish --tag=config