daVmixcool/google-recaptcha

PHP 前后端 Google reCAPTCHA 包。

0.8.2 2018-12-24 01:19 UTC

This package is auto-updated.

Last update: 2024-09-12 04:41:15 UTC


README

这是一个支持 Google reCAPTCHA v2 的前后端的 PHP 包。

要求

  • PHP 5.5 及以上版本

步骤

安装

Composer

运行以下命令通过 Composer 包含此包

composer require davmixcool/google-recaptcha

用法

简单易用。

use Davmixcool\GoogleRecaptcha;
	
	//include the recaptcha configurations globally
	$googleRecaptcha = new GoogleRecaptcha([
		'secret_key' => 'Your secret key',
		'site_key' => 'Your site key',
		'theme' => 'light'
	]);

	//Place the renderJs before the closing body tag.
	$googleRecaptcha->renderJs();

	//Place the renderCaptcha where you want to display the captcha.
	$googleRecaptcha->renderCaptcha();

	// Check if captcha was passed successfully 
	if ($googleRecaptcha->check()) {
	    // Perform success action

	} else {
	    // Throw an error if catcha was not solved successfully
	}

维护者

此包由 David Oti 和您维护!

许可协议

此包遵循 MIT 许可协议