PHP code example of zbrettonye / hcaptcha
1. Go to this page and download the library: Download zbrettonye/hcaptcha 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/ */
zbrettonye / hcaptcha example snippets
ZBrettonYe\HCaptcha\HCaptchaServiceProvider::class,
'HCaptcha' => ZBrettonYe\HCaptcha\Facades\HCaptcha::class,
{!! HCaptcha::renderJs() !!}
{!! HCaptcha::renderJs('fr', true, 'recaptchaCallback') !!}
{!! HCaptcha::display() !!}
{!! HCaptcha::display(['data-theme' => 'dark']) !!}
{!! HCaptcha::displaySubmit('my-form-id', 'submit now!', ['data-theme' => 'dark']) !!}
$validate = Validator::make(Input::all(), [
'h-captcha-response' => '
'custom' => [
'h-captcha-response' => [
' or contact site admin.',
],
],
@if ($errors->has('h-captcha-response'))
<span class="help-block">
<strong>{{ $errors->first('h-captcha-response') }}</strong>
</span>
@endif
// prevent validation error on captcha
HCaptcha::shouldReceive('verifyResponse')
->once()
->andReturn(true);
// provide hidden input for your '
// prevent validation error on captcha
HCaptcha::shouldReceive('verifyResponse')
->once()
->andReturn(true);
// POST request, with request body including g-recaptcha-response
$response = $this->json('POST', '/register', [
'h-captcha-response' => '1',
'name' => 'John',
'email' => '[email protected] ',
'password' => '123456',
'password_confirmation' => '123456',
]);
et = 'CAPTCHA-SECRET';
$sitekey = 'CAPTCHA-SITEKEY';
$captcha = new \ZBrettonYe\HCaptcha\HCaptcha($secret, $sitekey);
if (! empty($_POST)) {
var_dump($captcha->verifyResponse($_POST['h-captcha-response']));
exit();
}
ssh
php artisan vendor:publish --provider="ZBrettonYe\HCaptcha\HCaptchaServiceProvider"