PHP code example of mcnub / nextcaptcha-laravel

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

    

mcnub / nextcaptcha-laravel example snippets


use NextCaptcha\Facades\NextCaptcha;

// Solve reCAPTCHA v2
$result = NextCaptcha::recaptchaV2(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key'
);

// Get balance
$balance = NextCaptcha::getBalance();

use NextCaptcha\NextCaptchaAPI;

class CaptchaController extends Controller
{
    public function __construct(
        private NextCaptchaAPI $captcha
    ) {}

    public function solve()
    {
        $result = $this->captcha->recaptchaV2(
            websiteUrl: 'https://example.com',
            websiteKey: 'site-key'
        );
        
        return response()->json($result);
    }
}

$result = NextCaptcha::recaptchaV2(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    recaptchaDataSValue: '',  // optional
    isInvisible: false,       // optional
    apiDomain: '',           // optional
    pageAction: '',          // optional
    websiteInfo: ''          // optional
);

$result = NextCaptcha::recaptchaV2Enterprise(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    enterprisePayload: [],    // optional
    isInvisible: false,       // optional
    apiDomain: '',           // optional
    pageAction: '',          // optional
    websiteInfo: ''          // optional
);

$result = NextCaptcha::recaptchaV3(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    pageAction: '',          // optional
    apiDomain: '',           // optional
    proxyType: '',          // optional
    proxyAddress: '',       // optional
    proxyPort: 0,           // optional
    proxyLogin: '',         // optional
    proxyPassword: '',      // optional
    websiteInfo: ''         // optional
);

$result = NextCaptcha::hCaptcha(
    websiteUrl: 'https://example.com',
    websiteKey: 'site-key',
    isInvisible: false,      // optional
    enterprisePayload: [],   // optional
    proxyType: '',          // optional
    proxyAddress: '',       // optional
    proxyPort: 0,           // optional
    proxyLogin: '',         // optional
    proxyPassword: ''       // optional
);
bash
php artisan vendor:publish --tag=nextcaptcha-config