2017 © Pedro Peláez
 

library recaptcha

ReCaptcha Client

image

neutron/recaptcha

ReCaptcha Client

  • Wednesday, September 3, 2014
  • by romain
  • Repository
  • 1 Watchers
  • 28 Stars
  • 105,960 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 13 Forks
  • 3 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Guzzled PHP ReCaptcha

Build Status, (*1)

This is a Object Oriented PHP port of the original ReCaptcha lib., (*2)

It's been designed to be testable and uses Guzzle as a transport layer., (*3)

  • see https://developers.google.com/recaptcha/docs/customization

Install

The recommended way to use ReCaptcha is through composer., (*4)

{
    "require": {
        "neutron/recaptcha": "~0.1.0"
    }
}

Silex Service Provider

A simple Silex service provider :, (*5)

use Neutron\ReCaptcha\ReCaptcha;
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
use Silex\Application;

$app = new Application();
$app->register(new ReCaptchaServiceProvider(), array(
    'recaptcha.public-key'  => 'fdspoksqdpofdkpopgqpdskofpkosd',
    'recaptcha.private-key' => 'lsdmkzfqposfomkcqdsofmsdkfkqsdmfmqsdm',
));

// $captcha is an instance of Neutron\ReCaptcha\Response
$captcha = $app['recaptcha']->bind($app['request']);

if ($captcha->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :( " . $captcha->getError();
}

Usage Example

To display a captcha to the client :, (*6)

  • Initialize your captcha object :
use Neutron\ReCaptcha\ReCaptcha;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);
  • In your template :


  • Server side :
use Neutron\ReCaptcha\ReCaptcha;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);
$response = $recaptcha->checkAnswer($_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);

if ($response->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :(";
}

Bind Symfony Request

A shortcut exists to bind a Symfony Request to ReCaptcha :, (*7)

use Neutron\ReCaptcha\ReCaptcha;
use Symfony\Component\HttpFoundation\Request;

$recaptcha = ReCaptcha::create($publicKey, $privateKey);
$response = $recaptcha->bind(Request::createFromGlobals());

if ($response->isValid()) {
    echo "YEAH !";
} else {
    echo "Too bad dude :( " . $response->getError();
}

License

This project is licensed under the MIT license., (*8)

The Versions

03/09 2014

dev-master

9999999-dev

ReCaptcha Client

  Sources   Download

MIT

The Requires

 

The Development Requires

14/02 2013

0.1.3

0.1.3.0

ReCaptcha Client

  Sources   Download

MIT

The Requires

 

The Development Requires

14/02 2013

0.1.2

0.1.2.0

ReCaptcha Client

  Sources   Download

MIT

The Requires

 

The Development Requires

14/02 2013

0.1.1

0.1.1.0

ReCaptcha Client

  Sources   Download

MIT

The Requires

 

The Development Requires

13/02 2013

0.1.0

0.1.0.0

ReCaptcha Client

  Sources   Download

MIT

The Requires