resolventa/stopforumspam-php-api
Composer 安装命令:
composer require resolventa/stopforumspam-php-api
包简介
PHP API for StopForumSpam service. See https://www.stopforumspam.com for details.
关键字:
README 文档
README
Composer friendly PHP API library and response analyzer for StopForumSpam service.
Requirements
- PHP >= 8.1
- cURL extension
Installation
composer require resolventa/stopforumspam-php-api
Usage
See example.php and tests/UseCaseTest.php for usage examples.
<?php use Resolventa\StopForumSpamApi\ResponseAnalyzer; use Resolventa\StopForumSpamApi\ResponseAnalyzerSettings; use Resolventa\StopForumSpamApi\StopForumSpamApi; use Resolventa\StopForumSpamApi\Exception\StopForumSpamApiException; include 'vendor/autoload.php'; $stopForumSpamApi = new StopForumSpamApi(); /** * Set up Email, IP and Username to be checked * You can use only one, two or all three together * * Use $stopForumSpamApi->checkIp('135.34.23.33'); if only IP address need to be checked */ $stopForumSpamApi ->checkEmail('test@test-domain.com') ->checkIp('135.34.23.33') ->checkUsername('someGreatUsername'); /** * Get Response from StopForumSpam service */ $response = $stopForumSpamApi->getCheckResponse(); /** * You can analyze response on your own or use Resolventa\StopForumSpamApi\ResponseAnalyzer to make decision * See ResponseAnalyzer usage below */ var_dump($response); /** * Create analyzer instance with $response and default analyser settings * * Or customize analyser settings to your needs * $settings = new ResponseAnalyzerSettings(); * $settings->setMinSpamFlagsCount(2); * $settings->setMinFlagAppearanceFrequency(10); * $settings->setFlagLastSeenDaysAgo(14); * $settings->setConfidenceThreshold(70); */ $analyzer = new ResponseAnalyzer(new ResponseAnalyzerSettings()); try { if($analyzer->isSpammerDetected($response)) { echo "Spam user detected. \n"; } else { echo "User is ok. \n"; } } catch (StopForumSpamApiException $e) { echo 'Bad response: ', $e->getMessage(), "\n"; exit(); }
Response analyzer
The library is included with an analyzer class to check StopForumSpam API response and decide if user is spammer or not.
Default analyzer settings
See StopForumSpam API documentation to understand given analyzer settings.
$confidenceThreshold = 90If response confidence equal or above$confidenceThreshold, user is detected as spammer.$minFlagAppearanceFrequency = 5If flag (ip, email, username) appears in spam reports less than$minFlagAppearanceFrequencyvalue, user is NOT detected as spammer.$flagLastSeenDaysAgo = 7If flag (ip, email, username) was last time reported as spam more than$flagLastSeenDaysAgodays ago, user is NOT detected as spammer.$minSpamFlagsCount = 1Minimum number of flags (ip, email, username) detected as spam to detect user as spammer.
Analyzer usage
// Create analyzer settings with default values $settings = new ResponseAnalyzerSettings(); // Update any setting with your preferable value $settings->setMinSpamFlagsCount(2); $settings->setMinFlagAppearanceFrequency(10); $settings->setFlagLastSeenDaysAgo(14); $settings->setConfidenceThreshold(70); // Start analyzer with given settings $analyzer = new ResponseAnalyzer(new ResponseAnalyzerSettings()); // Validate response with the give analyzer settings if($analyzer->isSpammerDetected($response)) { // Throw away that spam registration }
Submit spam reports
To submit spam reports you need to get StopForumSpam API key.
For usage example see test/SubmitReportTest.php
// Instantiate StopForumSpamApi with API key $stopForumSpamApi = new StopForumSpamApi(self::API_KEY); // Submit report $result = $stopForumSpamApi->submitSpamReport(string $username, string $ip, string $email, string $evidence);
resolventa/stopforumspam-php-api 适用场景与选型建议
resolventa/stopforumspam-php-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.74k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 12 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「stopforumspam」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 resolventa/stopforumspam-php-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 resolventa/stopforumspam-php-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 resolventa/stopforumspam-php-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.
Laravel Spam Protector class to check ip, name, email for spam that uses the StopForumSpam Api https://www.stopforumspam.com/usage
A PSR-7 compatible library for making CRUD API endpoints
Wrapper for API www.stopforumspam.com (api.stopforumspam.org)
Alfabank REST API integration
Laravel Spam Protector class to check ip, name, email for spam that uses the StopForumSpam Api https://www.stopforumspam.com/usage
统计信息
- 总下载量: 5.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-12