2017 © Pedro Peláez
 

library recaptcha

reCAPTCHA v2 class

image

phelium/recaptcha

reCAPTCHA v2 class

  • Sunday, May 13, 2018
  • by ShevAbam
  • Repository
  • 4 Watchers
  • 29 Stars
  • 3,160 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 8 Versions
  • 51 % Grown

The README.md

reCAPTCHA

Installation

With Composer, add this line to your require section :, (*1)

"phelium/recaptcha": "dev-master"

Then run composer update., (*2)

Initilization

require 'vendor/autoload.php';

use Phelium\Component\reCAPTCHA;

To initialize reCAPTCHA, you must provide your site key and your secret key.
There is two possible ways :, (*3)

$reCAPTCHA = new reCAPTCHA('your site key', 'your secret key');

or, (*4)

$reCAPTCHA = new reCAPTCHA();
$reCAPTCHA->setSiteKey('your site key');
$reCAPTCHA->setSecretKey('your secret key');

Usage

To generate the script tag, use :, (*5)

$reCAPTCHA->getScript();

To generate the HTML block, use in your form :, (*6)

$reCAPTCHA->getHtml();

Checking the server side, in your form validation script :, (*7)

if ($reCAPTCHA->isValid($_POST['g-recaptcha-response']))
{
    // do whatever you want, the captcha is valid
}
else
{
    // Show errors
    var_dump($reCAPTCHA->getErrorCodes());
}

Customization

Theme

Several themes are available : light (default) or dark., (*8)

$reCAPTCHA->setTheme('dark');

Language

You can change the language of reCAPTCHA. Check https://developers.google.com/recaptcha/docs/language for more information.
By default, the language is automatically detected., (*9)

$reCAPTCHA->setLanguage('it');

Type

Several types are available : image (default) or audio., (*10)

$reCAPTCHA->setType('audio');

Size

Two sizes are available : normal (default) or compact., (*11)

$reCAPTCHA->setType('compact');

Full example

Here is an example :, (*12)

<?php
require 'vendor/autoload.php';
use Phelium\Component\reCAPTCHA;

$reCAPTCHA = new reCAPTCHA('your site key', 'your secret key');
?>

<html>
<head>
    <title>reCAPTCHA example</title>
    <?php echo $reCAPTCHA->getScript(); ?>
</head>

<body>

<?php
if (isset($_POST['name']))
{
    var_dump($_POST);

    if ($reCAPTCHA->isValid($_POST['g-recaptcha-response']))
    {
        echo '<br>-- Captcha OK ! --<br>';
    }
}
?>

<form action="#" method="POST">
    <input type="text" name="name" placeholder="name">

    <?php echo $reCAPTCHA->getHtml(); ?>

    <input type="submit">
</form>

</body>
</html>

The Versions

13/05 2018

dev-master

9999999-dev https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GNU GPL 2.0 GPL-2.0-only

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

13/05 2018

1.0.8

1.0.8.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GPL-2.0-only

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

16/04 2018

1.0.7

1.0.7.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GPL-2.0-only

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

20/03 2018

1.0.6

1.0.6.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GPL-2.0-only

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

05/02 2018

1.0.5

1.0.5.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GPL-2.0-only

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

14/08 2017

1.0.3

1.0.3.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GNU GPL 2.0

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

12/02 2015

1.0.2

1.0.2.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GNU GPL 2.0

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha

13/01 2015

1.0

1.0.0.0 https://github.com/shevabam/recaptcha

reCAPTCHA v2 class

  Sources   Download

GNU GPL 2.0

The Requires

  • php >=5.3.0

 

by Avatar ShevAbam

captcha google recaptcha