qvbilam / audit
There is no license information available for the latest version (1.1.0) of this package.
1.1.0
2023-03-13 15:50 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- mockery/mockery: ^1.5
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2024-11-17 12:16:51 UTC
README
说明
使用 数美天净 智能审核
安装
通过 composer 拉取包
{ "require": { "qvbilam/audit": "1.*" } }
或者通过命令: composer require qvbilam/audit
使用
验证文本
use Qvbilam\Audit\Audit; $audit = new Audit("key", "appId"); $response = $audit->text("文本内容"); return $response->toJson();
验证图片
use Qvbilam\Audit\Audit; $audit = new Audit("key", "appId"); $response = $audit->image("图片地址"); return $response->toJson();
返回结果示例
{ "requestId":"43d9b42af973166ee6127b38aaa8ed88", "status":"-1", "description":"辱骂:不文明用语:轻度不文明用语", "text":"草泥马", "riskType":"abuse", "score":71 }
Laravel 中使用
.env
文件添加配置:
# 应用key AUDIT_KEY=xxxx # 应用appId AUDIT_APP_ID=xxxx
配置 config/services.php :
'audit' => [ "key" => env("AUDIT_KEY"), "app_id" => env("AUDIT_APP_ID"), ],
通过自动注入方式使用:
use Qvbilam\Audit\Audit; public function auditText(Request $request, Audit $audit) { $text = $request->query("txt"); $audit = $audit->text($text); return $audit->toJson(); }
或者使用服务名称方式使用:
use Qvbilam\Audit\Audit; public function auditTextInjection(Request $request) { $text = $request->query("txt"); return app("audit")->text($text)->toJson(); }