notafacil/zf3-coinhive-captcha

为 Zend Framework 2 & 3 (ZF2 / ZF3) 设计的 CoinHive Captcha 模块

2.0.1 2018-04-05 19:17 UTC

This package is not auto-updated.

Last update: 2024-09-21 10:22:25 UTC


README

使用 coinhive.com 验证码的简单方法

安装

使用 composer

只需将以下行添加到您的需求中

composer require notafacil/zf3-coinhive-captcha

然后运行

php composer.phar update

由于使用 Adapter\Socket 时存在 SSL-Cert 问题,请安装 php-curl!

然后在您的 application.config.php 中激活该模块

```php
return array(
    'modules' => array(
        // ...
        'CoinHiveCaptcha',
    ),
    // ...
);
```

获取您的私钥

要使用此服务,您必须使用 CoinHive 账户在 CoinHive 上注册。

用法

使用 Zend\From

只需将以下行添加到您的表单创建中

$element = new \Zend\Captcha\Captcha('coinhive-captcha-token');
$element->setCaptcha(new CoinHiveCaptcha\CoinHiveCaptcha(array('secret_key' => 'YOUR_SECRET', 'public_key' => 'YOUR_PUBLIC_KEY', 'hashes' => 512)));
$form->add($element);

记得将此元素添加到您的验证链中。

它与其他内置验证码解决方案的作用相同。

使用 ServiceManager

如果您想自己实现视图,只需使用 Service\CoinHiveCaptchaService。它处理您代码与 CoinHive API 之间的全部通信。

$recaptcha = $serviceLocator->get('CoinHiveCaptcha\Service\CoinHiveCaptchaService');