PHPackages                             singiu/neteaseim - 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. singiu/neteaseim

ActiveLibrary

singiu/neteaseim
================

1.1.0(8y ago)31821MITPHPPHP &gt;=5.2.0

Since Apr 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Singiu/neteaseim)[ Packagist](https://packagist.org/packages/singiu/neteaseim)[ RSS](/packages/singiu-neteaseim/feed)WikiDiscussions master Synced 2w ago

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

对网易云信 IM 服务端 API 接口的 PHP 封装
===========================

[](#对网易云信-im-服务端-api-接口的-php-封装)

[![Latest Stable Version](https://camo.githubusercontent.com/0679977c8514f67e8ef51fccab73a2183c8d653f01bb533bdd1cdbebf064a932/68747470733a2f2f706f7365722e707567782e6f72672f73696e6769752f6e657465617365696d2f762f737461626c65)](https://packagist.org/packages/singiu/neteaseim)[![Total Downloads](https://camo.githubusercontent.com/22d57894288d5c427faea7514341f9682cce9f467b32570e65dcb4a786adb7b9/68747470733a2f2f706f7365722e707567782e6f72672f73696e6769752f6e657465617365696d2f646f776e6c6f616473)](https://packagist.org/packages/singiu/neteaseim)[![Latest Unstable Version](https://camo.githubusercontent.com/96c03ae181d3cfd309adbc379cf2f7694b3b6aed86524a64a72c6eaf11b7af3d/68747470733a2f2f706f7365722e707567782e6f72672f73696e6769752f6e657465617365696d2f762f756e737461626c65)](https://packagist.org/packages/singiu/neteaseim)[![License](https://camo.githubusercontent.com/c38572f3814a13f6510caea8dfeab9c7264b0d90d5fbdd261f1ef5e14721feba/68747470733a2f2f706f7365722e707567782e6f72672f73696e6769752f6e657465617365696d2f6c6963656e7365)](https://packagist.org/packages/singiu/neteaseim)[![composer.lock available](https://camo.githubusercontent.com/dac3fc52d75e1a64f0ff0ac8ecdfe51192ff3d6c10e73af31660dd12ae7ba37c/68747470733a2f2f706f7365722e707567782e6f72672f706870756e69742f706870756e69742f636f6d706f7365726c6f636b)](https://packagist.org/packages/phpunit/phpunit)

只封装了部分接口（其实就是我项目中使用到的接口），所以下载使用前请务必先详细阅读此文档，看看有没有你想要的功能。（当然你也可以自己补充你自己的需求，源码灰常简单的，欢迎发起 Pull request 帮助完善哦 😏 ）

如果没有你想要的功能，可以在 Issue 上发起需求，我会尽量满足，谢谢支持 🙇

安装
--

[](#安装)

```
composer require singiu/neteaseim
```

使用
--

[](#使用)

实例化类需要 appKey 和 appSecret，这两个东西需要云网易云申请。

```
$app_key = 'Your App Key';
$app_secret = 'Your App Secret';

$im = new NeteaseIM($app_key, $app_secret);
```

### 网易云通信 ID

[](#网易云通信-id)

#### 创建网易通信云 ID

[](#创建网易通信云-id)

```
$acc_id = 'singiu';

$data = array(
    'name' => 'User nick name',
    'icon' => 'Avatar url',
    // ...
    // 其它参数可以参考网易云的文档：http://dev.netease.im/
);

$im->create($acc_id, $data);
```

#### 更新网易云通信ID

[](#更新网易云通信id)

官网描述：网易云通信ID基本信息更新。 但其实我自己并不太清楚这个接口的用意 😴，有用的是可以指定修改用户的登录 token。 而 refreshToken 方法是官方后台刷新一个 token 并返回给你。

```
$acc_id = 'singiu';
// 只接受两个参数：
$data = array(
    'props' => 'JSON 属性，第三方可选填，最大长度 1024 字符。',
    'token' => '网易云通信 ID 可以指定登录 token 值，最大长度 128 字符。',
);

$im->update($acc_id, $data);
```

#### 更新并获取新的 token

[](#更新并获取新的-token)

这里的 token 指的是*网易云通信 ID*的登录密码，可以理解为这是修改登录密码的接口。

```
$acc_id = 'singiu';
$result = $im->refreshToken($acc_id);
$new_token = $result['token'];
```

#### 封禁网易云信 ID

[](#封禁网易云信-id)

- 1.第三方禁用某个网易云通信ID的IM功能；
- 2.封禁网易云通信ID后，此ID将不能登陆网易云通信imserver。

```
$acc_id = 'singiu';
$need_kick = true; // 是否踢掉被禁用户（强迫下线），可以不传这个参数，不传默认为 false。
$im->block($acc_id, $need_kick);
```

#### 解禁网易云通信 ID

[](#解禁网易云通信-id)

```
$acc_id = 'singiu';
$im->unblock($acc_id);
```

### 用户名片

[](#用户名片)

#### 获取用户名片

[](#获取用户名片)

获取单一用户名片资料

```
$acc_id = 'singiu';
$user_info = $im->getUserInfo($acc_id);
echo $user_info['email']; // junxing.lin@foxmail.com
```

获取多个用户名片资料（只要传一个acc\_id的数据就行，注意方法名也不一样，多一个 **s** 😈 ）

```
$acc_ids = ['singiu', 'jue'];
$users_info = $im->getUsersInfo($acc_ids);
var_dump($users_info);
```

#### 更新用户名片

[](#更新用户名片)

```
// 请求方式和参数都与 `$im->create($accId, $data)` 一样，只是方法名改为 `updateUserInfo()`。
$acc_id = 'singiu';
$data = array(
    'name' => 'Star',
    'email' => 'junxing.lin@foxmail.com',
    // ...
);

$im->updateUserInfo($acc_id, $data);
```

### 消息功能

[](#消息功能)

#### 发送普通文本消息

[](#发送普通文本消息)

```
$from = 'singiu'; // 发送者 accid
$to = 'jue'; // 接收者 accid
$text = 'Hello World!';

$im->sendTextMessage($from, $to, $text);
```

#### 发送自定义系统通知

[](#发送自定义系统通知)

这里的自定义系统通知类似于透传消息。

```
$from = 'singiu';
$to = 'jue';
$attach = array(
    'customDataKey1' => 'customDataValue1',
    'customDataKey2' => 'customDataValue2',
    // ...
    // 这里的数据都是自定义的，方法会把它转成 JSON 格式透传给客户端。
);

$im->sendAttachMessage($from, $to, $attach);
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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 ~63 days

Total

2

Last Release

2937d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3905448?v=4)[Star](/maintainers/Singiu)[@Singiu](https://github.com/Singiu)

---

Top Contributors

[![Singiu](https://avatars.githubusercontent.com/u/3905448?v=4)](https://github.com/Singiu "Singiu (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/singiu-neteaseim/health.svg)

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

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k455.2M1.5k](/packages/phpseclib-phpseclib)[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k81.2M544](/packages/mpdf-mpdf)[defuse/php-encryption

Secure PHP Encryption Library

3.9k170.7M239](/packages/defuse-php-encryption)[friendsofsymfony/oauth-server-bundle

Symfony2 OAuth Server Bundle

1.1k15.3M135](/packages/friendsofsymfony-oauth-server-bundle)[yiisoft/yii2-httpclient

HTTP client extension for the Yii framework

43011.4M323](/packages/yiisoft-yii2-httpclient)[fedeisas/laravel-mail-css-inliner

Inline the CSS of your HTML emails using Laravel

5984.7M3](/packages/fedeisas-laravel-mail-css-inliner)

PHPackages © 2026

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