PHPackages                             paragonie/recaptcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. paragonie/recaptcha

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

paragonie/recaptcha
===================

A fork of Google's PHP ReCAPTCHA Client with Proxy support.

v2.1.0(8y ago)714.9k↓45%1[1 PRs](https://github.com/paragonie/recaptcha/pulls)1BSD-3-ClausePHPPHP &gt;=5.5

Since Mar 12Pushed 7y ago4 watchersCompare

[ Source](https://github.com/paragonie/recaptcha)[ Packagist](https://packagist.org/packages/paragonie/recaptcha)[ Docs](http://www.google.com/recaptcha/)[ RSS](/packages/paragonie-recaptcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (7)Used By (1)

PIE ReCAPTCHA
=============

[](#pie-recaptcha)

This is a fork of Google's PHP ReCAPTCHA client that allows you to pass cURL options, e.g. to proxy requests over Tor.

```
$curl = new ReCaptcha\RequestMethod\CurlPost(null, array(
    CURLOPT_PROXY => 'http://127.0.0.1:9050/',
    CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5
));
$recaptcha = new \ReCaptcha\ReCaptcha($secret, $curl);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
    // verified!
} else {
    $errors = $resp->getErrorCodes();
}
```

reCAPTCHA PHP client library
============================

[](#recaptcha-php-client-library)

[![Build Status](https://camo.githubusercontent.com/bc63564ea0d0462210903257922f725814f9c3395de410253da5fa44a6794898/68747470733a2f2f7472617669732d63692e6f72672f70617261676f6e69652f7265636170746368612e737667)](https://travis-ci.org/paragonie/recaptcha)[![Latest Stable Version](https://camo.githubusercontent.com/514f3ccf6b50dd8703a1388b7e0fced8b61435ddc759223408e015f6943fbb29/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f7265636170746368612f762f737461626c652e737667)](https://packagist.org/packages/paragonie/recaptcha)[![Total Downloads](https://camo.githubusercontent.com/f62e2f6d3d83ae978d7e08ddf29dfd8e215220099f6a5081ac150522e2eea05b/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f7265636170746368612f646f776e6c6f6164732e737667)](https://packagist.org/packages/paragonie/recaptcha)

- Repository:
- Version: 2.1.0
- License: BSD, see [LICENSE](LICENSE)

Description
-----------

[](#description)

reCAPTCHA is a free CAPTCHA service that protect websites from spam and abuse. This is Google authored code that provides plugins for third-party integration with reCAPTCHA.

Installation
------------

[](#installation)

### Composer (Recommended)

[](#composer-recommended)

[Composer](https://getcomposer.org/) is a widely used dependency manager for PHP packages. This reCAPTCHA client is available on Packagist as [`google/recaptcha`](https://packagist.org/packages/google/recaptcha) and can be installed either by running the `composer require` command or adding the library to your `composer.json`. To enable Composer for you project, refer to the project's [Getting Started](https://getcomposer.org/doc/00-intro.md)documentation.

To add this dependency using the command, run the following from within your project directory:

```
composer require paragonie/recaptcha "~2.1"

```

Alternatively, add the dependency directly to your `composer.json` file:

```
"require": {
    "paragonie/recaptcha": "~2.1"
}
```

### Direct download (no Composer)

[](#direct-download-no-composer)

If you wish to install the library manually (i.e. without Composer), then you can use the links on the main project page to either clone the repo or download the [ZIP file](https://github.com/google/recaptcha/archive/master.zip). For convenience, an autoloader script is provided in `src/autoload.php` which you can require into your script instead of Composer's `vendor/autoload.php`. For example:

```
require('/path/to/recaptcha/src/autoload.php');
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
```

The classes in the project are structured according to the [PSR-4](http://www.php-fig.org/psr/psr-4/) standard, so you may of course also use your own autoloader or require the needed files directly in your code.

### Development install

[](#development-install)

If you would like to contribute to this project or run the unit tests on within your own environment you will need to install the development dependencies, in this case that means [PHPUnit](https://phpunit.de/). If you clone the repo and run `composer install` from within the repo, this will also grab PHPUnit and all its dependencies for you. If you only need the autoloader installed, then you can always specify to Composer not to run in development mode, e.g. `composer install --no-dev`.

*Note:* These dependencies are only required for development, there's no requirement for them to be included in your production code.

Usage
-----

[](#usage)

First, register keys for your site at

When your app receives a form submission containing the `g-recaptcha-response`field, you can verify it using:

```
