Created
March 12, 2016 13:15
-
-
Save Hexodus/33144079415ae720fcec to your computer and use it in GitHub Desktop.
Google ReCaptcha secure token generation using slushie class from:
https://github.com/slushie/recaptcha-secure-token/blob/master/lib/ReCaptchaToken.php Secure token makes it possible to use ReCaptcha for testing on localhost.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
use ReCaptchaSecureToken\ReCaptchaToken as ReCaptchaToken; | |
require_once("ReCaptchaToken.php"); | |
//Generate recaptcha token | |
$recaptcha_config = [ | |
'site_key' => 'your-site-key', | |
'site_secret' => 'your-site-secret-key' | |
]; | |
$recaptcha_token = new ReCaptchaToken($recaptcha_config); | |
$recaptcha_session_id = uniqid('recaptcha'); | |
$recaptcha_secure_token = $recaptcha_token->secureToken($recaptcha_session_id); | |
//template file with the recaptcha | |
<div class="g-recaptcha" data-sitekey="<?= $recaptcha_config['site_key'] ?>" | |
data-stoken="<?= $recaptcha_secure_token ?>" ></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment