hedeqiang/antispam
Composer 安装命令:
composer require hedeqiang/antispam
包简介
网易易盾内容安全 PHP SDK
README 文档
README
网易云 易盾 内容安全 PHP SDK
在使用本扩展之前,你需要去 网易易盾 获取 secretId、secretKey、businessId
Installing
$ composer require hedeqiang/antispam -vvv
Usage
require __DIR__ .'/vendor/autoload.php'; use Hedeqiang\Antispam\Antispam; $config = [ 'account' => [ 'secretId' => '', 'secretKey' => '', ], 'text' => [ 'businessId' => '', ], 'image' => [ 'businessId' => '', ], 'audio' => [ 'businessId' => '', ], 'video' => [ 'businessId' => '', ], ]; $antispam = new Antispam($config);
文本
单文本检测
$response = $antispam->textScan(['content' => 'XXX']); or $params = [ 'content' => 'XXX','title' => 'XXX','dataId' => 123 ... ]; // 可只传 content 字段。 dataId、version 本 SDK 已经做处理,可传可不传 $extras = [ 'ip' => '10.0.0.1', 'account' => 'hedeqiang', ... ]; // 此参数可不传 $response = $antispam->textScan($params,$extras);
文本批量检测
$texts = [ ['content' => 'XXX','title' => 'XXX',...], ['content' => 'XXX','title' => 'XXX',...] ]; // 可以只填 Y 的值 。dataId 可不传 $extras = [ 'ip' => '10.0.0.1', 'account' => 'hedeqiang', ... ]; // 此参数可不传 $response = $antispam->textBatchScan($params,$extras);
文本离线结果获取
$response = $antispam->textCallback();
文本机器结果反馈接口
$feedback = [ ['taskId' => 'e8e13a01024345db8e04c0dfaed2ec50','version' => 'v1','level' => 0,'label' => 100] ]; $response = $antispam->textFeedback($feedback);
自定义文本关键词-添加
$params = [ 'category' => '100', 'keywords' => 'XXX,XXX,XXX,XXX,XXX,XXX,XXX' ]; $response = $antispam->addKeyWorld($params);
自定义关键词-删除
$ids =['23234140','23234141']; $response = $antispam->delKeyWorld($ids);
自定义关键词查询接口
$response = $antispam->textQuery(); // 也可传入制定参数 $params = [ 'id' => '23223254', 'keyword' => 'XXX', 'category' => 100, 'orderType' => 1, 'pageNum' => 100, 'pageSize' => 10, ]; $response = $antispam->textQuery($params);
图片
图片在线检测
$images = [ ['name' => '','type' => '','data' => '','callbackUrl' => ''], ['name' => '','type' => '','data' => '','callbackUrl' => ''], ['name' => '','type' => '','data' => '','callbackUrl' => ''], ['name' => '','type' => '','data' => '','callbackUrl' => ''], ]; // array $checkLabels = [],array $extras = [] $response = $antispam->imageScan($images);
More...
More...
在 Laravel 中使用
发布配置文件
php artisan vendor:publish --tag=antispam
编写 .env 文件
DUN_SECRET_ID=
DUN_SECRET_KEY=
DUN_TEXT_BUSINESS_ID=
DUN_IMAGE_BUSINESS_ID=
DUN_AUDIO_BUSINESS_ID=
DUN_VIDEO_BUSINESS_ID=
方法参数注入
参数和上面一样
use Hedeqiang\Antispam\Antispam; public function index(Antispam $antispam) { $response = $antispam->textScan(); }
服务名访问
public function index() { $response = app('antispam')->textScan(); }
Facades 门面使用(可以提示)
use Hedeqiang\Antispam\Facades\Antispam; $response = Antispam::green()->textScan();
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT
hedeqiang/antispam 适用场景与选型建议
hedeqiang/antispam 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.55k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hedeqiang/antispam 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hedeqiang/antispam 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-09