PHPackages                             slushie/recaptcha-secure-token - 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. [Security](/categories/security)
4. /
5. slushie/recaptcha-secure-token

ActiveLibrary[Security](/categories/security)

slushie/recaptcha-secure-token
==============================

Generate ReCaptcha-compatible secure tokens

1.1.1(10y ago)1580.1k8[1 issues](https://github.com/slushie/recaptcha-secure-token/issues)Apache-2.0PHPPHP &gt;= 5.3.3

Since Jul 28Pushed 10y ago2 watchersCompare

[ Source](https://github.com/slushie/recaptcha-secure-token)[ Packagist](https://packagist.org/packages/slushie/recaptcha-secure-token)[ Docs](https://github.com/slushie/recaptcha-secure-token)[ RSS](/packages/slushie-recaptcha-secure-token/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

ReCaptcha Secure Token
======================

[](#recaptcha-secure-token)

This library provides a PHP implementation of the ReCaptcha v2 [Secure Token](https://developers.google.com/recaptcha/docs/secure_token) algorithm.

Usage
-----

[](#usage)

You should add this library to your composer `require` section:

```
"require": {
  "slushie/recaptcha-secure-token": "~1.0",
  /* ... */
}

```

From within your PHP code, you can create an instance of the `ReCaptchaToken` class and pass in your `site_key` and `site_secret` values:

```
$config = ['site_key' => 'YOUR_SITE_KEY', 'site_secret' => 'YOUR_SITE_SECRET'];
$recaptchaToken = new \ReCaptchaSecureToken\ReCaptchaToken($config);

```

To generate a *secure token* you must provide a unique `session_id`:

```
$sessionId = uniqid('recaptcha');
$secureToken = $recaptchaToken->secureToken($sessionId);

```

Finally, use this token value in your HTML output. For example:

```
