neoan3-apps / hcaptcha
hcaptcha PHP 实现版本
v1.1.0
2020-08-04 00:19 UTC
Requires
- ext-json: *
- neoan3-apps/curl: ^1.0
Requires (Dev)
- phpunit/phpunit: ^8.5.8
This package is auto-updated.
Last update: 2024-09-04 08:45:08 UTC
README
⚠️ 我与hCaptcha没有任何关联 ⚠️
轻松集成 hCaptcha,一款能够
- 阻挡机器人;
- 为你赚钱;
- 注重隐私。
快速开始
<head> <script src="https://hcaptcha.com/1/api.js" async defer></script> ... </head> <body> <form action="endpoint.php" method="post"> ... <div class="h-captcha" data-sitekey="your-sitekey"></div> <input type="submit" value="send"> </form> </body>
- 现在在您的 PHP 后端
\Neoan3\Apps\Hcapture::setEnvironment([ 'siteKey' => 'your-sitekey', 'secret' => 'your-secret', 'apiKey' => 'your-api-key' ]); if(isset($_POST['my-form']) && \Neoan3\Apps\Hcapture::isHuman()) { ... do stuff }
hCapture neoan3 API
以下是一些您可以使用并设置 hCaptcha 到您项目中的方法。
环境设置
对于您的全局环境设置,请使用以下方法
// Set your own secret key setSecret(string $value); // API Key of hCaptcha linked to your account setApiKey(string $value); // Secret site key linked to your site // See: https://docs.hcaptcha.com/api#addnewsitekey setSiteKey(string $value); // With an array of environment variables provided, set all of them // This is a 'shortcut' for all three previous methods setEnvironment(array $environmentVariables);
hCaptcha 工具
要检索 hCaptcha 信息,以下是需要的方法
// Check if the hCaptcha verification was successful isHuman(); // Retrieve all statitics of the site corresponding to the // provided variables (an error value is returned in case of // invalid credentials) stats();
高级设置
您可以在文档的 配置页面 上获取更多有关高级设置的信息。