cleantalk/php-antispam

cleantalk.org 的反垃圾邮件服务的 PHP API。无形的垃圾邮件防护,无验证码,无拼图,无动物和无需数学计算。

3.1 2023-04-27 13:58 UTC

This package is auto-updated.

Last update: 2024-09-10 14:37:44 UTC


README

Build Status

Latest Stable Version

cleantalk.org 的反垃圾邮件服务的 PHP API。无形的垃圾邮件防护,无验证码,无拼图,无动物和无需数学计算。

API 如何阻止垃圾邮件?

API 使用几个简单的测试来阻止垃圾邮件发送者。

  • 垃圾邮件机器人签名。
  • 通过电子邮件、IP、网站域名进行黑名单检查。
  • JavaScript 可用性。
  • 对评论的相关性测试。

API 如何工作?

API 将评论的文本和几个之前批准的评论发送到服务器。服务器评估评论文本与主题的相关性,进行垃圾邮件测试,并最终提供解决方案 - 发布或手动审核评论。如果评论被置于手动审核,插件会在评论文本中添加说明,解释为何服务器拒绝发布。

要求

  • PHP 5.6 及以上版本
  • CURL 支持

您可以将插件存档解压缩到网站的根目录,或使用 composer 安装

composer require cleantalk/php-antispam

文本评论和用户注册的示例垃圾邮件测试

<?php
session_start();

$apikey = 'your_cleantalk_api_key';
$email_field = 'name_email_form_field';
$user_name_field = 'name_user_name_form_field';
$message_field = 'name_message_form_field';
$type_form = 'contact'; // use 'signup' for user signup form

// if downloaded, unzip and include the app:
require_once 'php-antispam/cleantalk-antispam.php';
// if install the app by composer package:
use Cleantalk\CleantalkAntispam;

//require_once "lib/cleantalk-php-patch.php"; -- PHP-FPM

$cleantalk_antispam = new CleantalkAntispam($apikey, $email_field, $user_name_field, $message_field, $type_form);
$api_result = $cleantalk_antispam->handle();
?>

<form method="post">
    <label for="login">Login:</label>
    <input type="text" name="name_user_name_form_field" id="login" />
    <br />
    <label for="email">Email:</label>
    <input type="text" name="name_email_form_field" id="email" value="" />
    <br />
    <label for="message">Message:</label>
    <textarea name="name_message_form_field" id="message"></textarea>
    <br />
    <input type="submit" />
</form>

<?php $cleantalk_antispam->frontendScript(); ?>

API 响应描述

API 返回 ($api_result) PHP 对象

  • allow (0|1) - 允许发布或否,换句话说,是垃圾邮件还是正常邮件
  • comment (字符串) - 服务器请求的注释。
  • id (字符串 MD5 HEX 哈希) - 唯一请求标识符。
  • errno (整数) - 错误号。errno == 0 表示请求成功。
  • errstr (字符串) - 错误问题的注释,errstr == null 表示请求成功。
  • account_status - 0 账户禁用,1 账户启用,-1 未知状态。

不想处理所有这些吗?

任何 CMS 或自定义网站的通用解决方案:[https://github.com/CleanTalk/php-uni](https://github.com/CleanTalk/php-uni)