PHPackages                             hedeqiang/antispam - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. hedeqiang/antispam

ActiveLibrary[Security](/categories/security)

hedeqiang/antispam
==================

网易易盾内容安全 PHP SDK

v1.1.0(5y ago)37.3k↑16.7%1MITPHP

Since Sep 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/hedeqiang/antispam)[ Packagist](https://packagist.org/packages/hedeqiang/antispam)[ RSS](/packages/hedeqiang-antispam/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

 antispam
==========

[](#-antispam-)

 网易云 易盾 内容安全 PHP SDK

在使用本扩展之前，你需要去 [网易易盾](https://dun.163.com/) 获取 `secretId`、`secretKey`、`businessId`

Installing
----------

[](#installing)

```
$ composer require hedeqiang/antispam -vvv
```

Usage
-----

[](#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...

[](#more)

在 Laravel 中使用
-------------

[](#在-laravel-中使用)

#### 发布配置文件

[](#发布配置文件)

```
php artisan vendor:publish --tag=antispam
```

##### 编写 .env 文件

[](#编写-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 门面使用(可以提示)

[](#facades-门面使用可以提示)

```
use Hedeqiang\Antispam\Facades\Antispam;
$response = Antispam::green()->textScan();
```

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/hedeqiang/antispam/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/hedeqiang/antispam/issues).
3. 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
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Total

2

Last Release

2042d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ac33cc87fe5ba7f0b8791f5b3453501e83b55ec9a5a209728817ff119635a72?d=identicon)[hedeqiang](/maintainers/hedeqiang)

---

Top Contributors

[![hedeqiang](https://avatars.githubusercontent.com/u/31909061?v=4)](https://github.com/hedeqiang "hedeqiang (21 commits)")

### Embed Badge

![Health badge](/badges/hedeqiang-antispam/health.svg)

```
[![Health](https://phpackages.com/badges/hedeqiang-antispam/health.svg)](https://phpackages.com/packages/hedeqiang-antispam)
```

###  Alternatives

[akaunting/laravel-firewall

Web Application Firewall (WAF) package for Laravel

999465.8k2](/packages/akaunting-laravel-firewall)[paragonie/certainty

Up-to-date, verifiable repository for Certificate Authorities

2642.4M20](/packages/paragonie-certainty)[dgtlss/warden

A Laravel package that proactively monitors your dependencies for security vulnerabilities by running automated composer audits and sending notifications via webhooks and email

8745.6k](/packages/dgtlss-warden)[acmephp/core

Raw implementation of the ACME protocol in PHP

38973.7k7](/packages/acmephp-core)[nickurt/laravel-pwned-passwords

PwnedPasswords for Laravel 11.x/12.x/13.x

187.5k](/packages/nickurt-laravel-pwned-passwords)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
