PHPackages                             ducks-project/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. ducks-project/recaptcha-secure-token

ActiveLibrary

ducks-project/recaptcha-secure-token
====================================

Generate ReCaptcha-compatible secure tokens

v1.0.2(2y ago)18MITPHPPHP &gt;=7.4

Since Feb 6Pushed 2y agoCompare

[ Source](https://github.com/ducks-project/recaptcha-secure-token)[ Packagist](https://packagist.org/packages/ducks-project/recaptcha-secure-token)[ Docs](https://github.com/ducks-project/recaptcha-secure-token/)[ RSS](/packages/ducks-project-recaptcha-secure-token/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

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

[](#recaptcha-secure-token)

Forked on [Slushie works](https://github.com/slushie/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": {
  "ducks-project/recaptcha-secure-token": "^1.0",
  /* ... */
}

```

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

```
$config = ['site_key' => 'YOUR_SITE_KEY', 'site_secret' => 'YOUR_SITE_SECRET'];
$manager = new \DucksProject\Component\RecaptchaSecureToken\Manager($config);

```

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

```
$sessionId = \uniqid('recaptcha');
$secureToken = $manager->generate($sessionId);

```

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

```
