定制 andrewdanilov/yii2-grecaptchav3 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andrewdanilov/yii2-grecaptchav3

Composer 安装命令:

composer require andrewdanilov/yii2-grecaptchav3

包简介

Classes and assets for using google recaptcha v3

README 文档

README

Classes and assets for using google recaptcha v3

Installation

The preferred way to install this extension is through composer.

Either run

composer require andrewdanilov/yii2-grecaptchav3 "~1.0.0"

or add

"andrewdanilov/yii2-grecaptchav3": "~1.0.0"

to the require section of your composer.json file.

Usage

In site config

<?php
// ...
return [
	// ...
	'components' => [
		// ...
		'recaptcha' => [
			'class' => \andrewdanilov\grecaptchav3\Recaptcha::class,
			'sitekey' => 'place your sitekey here', // optional, if not set, you need to define it in widget config
			'secret' => 'place yout secret here',
		],
	],
];

In controller action

<?php
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
	$token = Yii::$app->request->post('g-recaptcha-token');
	$action = Yii::$app->request->post('g-recaptcha-action');
	if (Yii::$app->recaptcha->verify($token, $action)) {
		// ...
		// additionally you can check your action here
	} else {
		$model->addError('recaptcha', 'Recaptcha error');
	}
}

In view

<form action="/register" method="post" id="registerForm">
	<!-- form fields -->
</form>

<?= \andrewdanilov\grecaptchav3\RecaptchaInit::widget([
	'formID' => 'registerForm',
	'action' => 'my_register_action', // optional, default is <controller_id>_<action_id>_<widget_id>
	'sitekey' => 'place your sitekey here', // optional, if you defined sitekey in component config
]) ?>

Widget param action must contain only chars from set [A-Za-z_] and has to be unique per form on page.

统计信息

  • 总下载量: 337
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固