haibin2017 / easy-yunxin by haibin2017
forked from PINKONG/neteasy-yunxin

网易云信服务端sdk for laravel/lumen
15
0
0
Package Data
Maintainer Username: haibin2017
Maintainer Contact: me@pinchsun.com (Pinch Sun)
Package Create Date: 2020-05-20
Package Last Update: 2020-07-27
Language: PHP
License: Unknown
Last Refreshed: 2024-04-26 03:26:25
Package Statistics
Total Downloads: 15
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0

neteasy-yunxin


网易云信 服务端sdk for Laravel5 / Lumen. based on salamander-mh/YunXinHelper.

Installation

Require this package with composer by using the following command:

$ composer require haibin2017/easy-yunxin

Then, add the service provider:

If you are using Laravel, add the service provider to the providers array in config/app.php:

[
    'providers' => [
        Woshuo\YunXin\YunXinServiceProvider::class,
    ],
]

Laravel 5.5+ 会自动注册服务提供者可过滤

If you are using Lumen, append the following code to bootstrap/app.php:

$app->register(Woshuo\YunXin\YunXinServiceProvider::class);

Configuration

The defaults are set in config/yunxin.php. Copy this file to your own config directory to modify the values. You can publish the config using this command:

php artisan vendor:publish --provider="Woshuo\YunXin\YunXinServiceProvider"

If you are using Lumen, append the following code to bootstrap/app.php:

$app->configure('yunxin');

Usage

实例化

use Woshuo\YunXin\Entrance;

$appKey = config('yunxin.app_key');
$appSecret = config('yunxin.app_secret');
$helper = new Entrance($appKey, $appSecret);
$user = $helper->user();
$chat = $helper->chat();

用户

# 创建用户
$user->create($accid, $name, $icon);


# 用户基本信息更新
$user->update($accid, $token);


# 封禁用户
$user->block($accid);


# 解禁用户
$user->unblock($accid);


# 更新用户名片
$user->updateUserInfo($accid, $name, $icon);


# 批量获取用户名片
$user->getUserInfos($accids);

消息功能

# 文本消息
$chat->sendTextMsg($accidFrom, $to, $open, $text);

# 图片消息
$chat->sendPictureMsg($accidFrom, $to, $open,
        $picName, $picMD5, $picUrl, $picExt, $picWidth, $picHeight, $picSize);

# 批量文本消息
$chat->sendTextBatchMsg($accidFrom, $accidsTo, $text);


# 发送自定义系统通知
$chat->sendAttachMsg($from, CHAT::CHAT_ONT_TO_ONE, $to, $attach);

License

The package is open-sourced software licensed under the MIT license.