oposs / silverstripe-hcaptcha
使用 hCaptcha 保护您的表单
0.1.2
2023-02-09 12:11 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- silverstripe/cms: ^4
- silverstripe/framework: ^4
- silverstripe/spamprotection: ~3.0
README
使用 hCaptcha 保护您的表单,这是一个符合 GDPR、CCPA、LGPD、PIPL 等规范的垃圾邮件防护程序(根据其网站上的描述)
安装
在安装之前请确保满足以下要求
- SilverStripe 4.x
- SilverStripe Spam Protection 3.x
- PHP CURL 和 JSON
composer require oposs/silverstripe-hcaptcha
并将 hCaptcha 设置为您的默认垃圾邮件防护程序
SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension: default_spam_protector: Oposs\hCaptcha\hCaptchaProtector
配置
在您的 app/_config/hcaptcha.yml
Oposs\hCaptcha\Forms\hCaptchaField: site_key: 'your_site_key' # Make sure to set the key starting with 0x.. in quotes secret_key: 'your_secret_key' # To configure options listed here https://docs.hcaptcha.com/configuration api_configuration: recaptchacompat: 'off'
有关更多配置选项,请参阅 hCaptchaField.php 中的注释
使用方法
在 PHP 中
use Oposs\hCaptcha\hCaptchaProtector\Forms new hCaptchaField('SpamProtection', 'SpamProtection', null);
或者如果您使用 Userforms
故障排除
问题:当验证码错误或未解决时,用户会被重定向到主页
答案:这很可能是重定向问题,如果您的网站运行在代理后面,请查看 Director 的 alternate_base_url
属性(尽管使用频繁,但尚未进行文档记录...)
欢迎贡献 :)