PHP code example of canducci / recaptcha

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

    

canducci / recaptcha example snippets


"canducci/recaptcha": "1.0.*" 


'providers' => array(
    ...,    
    Canducci\ReCaptcha\Providers\ReCaptchaServiceProvider::class,
),

'aliases' => array(
    ...,    
    'ReCaptcha' => Canducci\ReCaptcha\Facades\ReCaptcha::class,
),

public function post(ReCaptchaRequest $request, ReCaptcha $re)
{
    
}

public function v(Request $request, ReCaptcha $re)
{    
 
    $valid = $re->valid($request->get('g-recaptcha-response'));
    
    if ( $valid->success() )
    {
        //success
    }
    else
    {
        //not valid
        var_dump( $valid->errors() );
    }
}


$script = recaptcha_script(Canducci\ReCaptcha\ReCaptchaScriptRender::Onload, 
                           Canducci\ReCaptcha\ReCaptchaScriptLanguage::Armenian, 
                           'function_CallBack');
                           
$render = recaptcha_render(Canducci\ReCaptcha\ReCaptchaRenderTheme::Ligth, 
                           Canducci\ReCaptcha\ReCaptchaRenderDataType::Image, 
                           Canducci\ReCaptcha\ReCaptchaRenderDataSize::Normal, 
                           0, 
                           'function_CallBack', 
                           'function_dataExpiredCallBack');

use `Canducci\ReCaptcha\Facades\ReCaptcha as ReCaptchaFacade`
    
$script = ReCaptchaFacade::script(Canducci\ReCaptcha\ReCaptchaScriptRender::Onload, 
                                  Canducci\ReCaptcha\ReCaptchaScriptLanguage::Armenian, 
                                  'function_CallBack');
                                  
$render = ReCaptchaFacade::render(Canducci\ReCaptcha\ReCaptchaRenderTheme::Ligth, 
                                  Canducci\ReCaptcha\ReCaptchaRenderDataType::Image, 
                                  Canducci\ReCaptcha\ReCaptchaRenderDataSize::Normal, 
                                  0, 
                                  'function_CallBack', 
                                  'function_dataExpiredCallBack');

@recaptchascript(Canducci\ReCaptcha\ReCaptchaScriptRender::Onload, 
                 Canducci\ReCaptcha\ReCaptchaScriptLanguage::Armenian,
                 'function_CallBack')

@recaptcha(Canducci\ReCaptcha\ReCaptchaRenderTheme::Ligth, 
           Canducci\ReCaptcha\ReCaptchaRenderDataType::Image, 
           Canducci\ReCaptcha\ReCaptchaRenderDataSize::Normal, 
           0, 
           'function_CallBack', 
           'function_dataExpiredCallBack')
HTML
public function index1()
{
    return view('index1')
        ->with('script', recaptcha_script())
        ->with('captcha', recaptcha_render());
}