arcaptcha/arcaptcha-php

ArCaptcha 的 PHP 库

1.0.8 2024-07-20 12:54 UTC

This package is not auto-updated.

Last update: 2024-09-28 14:07:03 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

PHP ArCaptcha 库。此包支持 PHP 7.3+

内容列表

安装

使用 composer 安装此包

composer require arcaptcha/arcaptcha-php

配置

您可以通过传递 API 中的 SiteKey 和 SecretKey 来创建一个新的实例。您可以在 https://arcaptcha.ir/dashboard 获取它们。

use Mohammadv184\ArCaptcha\ArCaptcha;

$ArCaptcha = new ArCaptcha($siteKey, $secretKey);

// To set options like color,lang,...
$ArCaptcha = new ArCaptcha($siteKey, $secretKey,['lang'=>'en','theme'=>'dark']);

要查看小部件上的可用选项,请参见 此处

如何使用

如何使用 ArCaptcha。

小部件使用

要在表单上显示 ArCaptcha,请使用类来渲染脚本标签和小部件。

<?php echo $ArCaptcha->getScript() ?>
<form method="POST">
    <?php echo $ArCaptcha->getWidget() ?>
    <input type="submit" value="Submit" />
</form>

注意:您可以将如颜色、lang 等可用小部件选项传递给 getWidget 函数

验证响应

在提交后,使用类来验证响应。您会得到真或假的反馈

if ($ArCaptcha->verify($_POST["arcaptcha-response"])) {
    echo "OK!";
} else {
    echo "FAILED!";
}

隐形模式

要查看此库中隐形模式的工作方式,请参阅此 示例

鸣谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件