pablosanches / hcaptcha
hCaptcha 的简单封装
dev-master
2021-09-30 11:02 UTC
Requires
- pablosanches/owl: 1.0.*
This package is auto-updated.
Last update: 2024-09-29 05:56:55 UTC
README
快速开始
<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 后端
require('../vendor/autoload.php'); use PabloSanches\hCaptcha; $hCaptcha = new hCaptcha('your-secret-key'); $hCaptchaResult = $hCaptcha->challenge($_POST['h-captcha-response']); $isHuman = $hCaptchaResult->isHuman(); // True or False if (!$isHuman) { $errors = $hCaptchaResult->getErrors(); // An array with all errors }
享受它 ;)