PHP code example of beingnikhilesh / googlerecaptcha

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

    

beingnikhilesh / googlerecaptcha example snippets


use beingnikhilesh\GoogleRecaptcha\GoogleRecaptcha;

/**
* Pass the $token and $action to the Validate Function
* @$token Token received from POST Request
* @$action passed in View page and received via POST Request
*
* @ response    TRUE  - If request is Human
*               FALSE - If the request is ROBOT
*/  
$isValid = GoogleRecaptcha::_validate($token, $action);

/*
* Additionally if you want to Pass the Google Secret and Google Key Manually Everytime, you can do so as below
* @$googleSecret    Google Secret recieved from Google Recaptcha Site 
* @$googleKey       Google Key recieved from Google Recaptcha Site
*
* @return           NULL
*/
GoogleRecaptcha::credentials($googleSecret, $googleKey);