PHP code example of maatify / google-recaptcha-v2

1. Go to this page and download the library: Download maatify/google-recaptcha-v2 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/ */

    

maatify / google-recaptcha-v2 example snippets



/**
 * Created by Maatify.dev
 * User: Maatify.dev
 * Date: 2024-08-08
 * Time: 5:19 PM
 * https://www.Maatify.dev
 */
 
use Maatify\GoogleRecaptchaV2\GoogleReCaptchaV2Validation;

google_recaptcha_v2->setHostname('maatify.dev');

// ===== if you want to validate score (invisible only)
$google_recaptcha_v2->setScore(0.5);

// ===== if you want to validate action (invisible only)
$google_recaptcha_v2->setAction('login');

// ===== get result in array format
$result = $google_recaptcha_v2->getResponse();

// ====== get bool of validation 
$result = $google_recaptcha_v2->isSuccess();

// ====== using maatify json on error response with json code with die and if success there is no error
$google_recaptcha_v2->jsonErrors();