haibin2017 / easy-yunxin
此包的最新版本(0.07)没有可用的许可信息。
为 Laravel/Lumen 提供的网易云信服务端 SDK
0.07
2020-05-22 11:14 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^6.3
README
基于 salamander-mh/YunXinHelper 的网易云信服务端 SDK for Laravel5 / Lumen。请访问 网易云信 获取更多信息。
安装
使用以下命令通过 Composer 安装此包:
$ composer require haibin2017/easy-yunxin
然后,添加服务提供者
如果你使用 Laravel,将服务提供者添加到 config/app.php
文件中的 providers 数组中
[ 'providers' => [ Woshuo\YunXin\YunXinServiceProvider::class, ], ]
Laravel 5.5+ 会自动注册服务提供者,可过滤
如果你使用 Lumen,将以下代码添加到 bootstrap/app.php
文件中
$app->register(Woshuo\YunXin\YunXinServiceProvider::class);
配置
默认值设置在 config/yunxin.php
文件中。将此文件复制到你的配置目录以修改值。你可以使用以下命令发布配置:
php artisan vendor:publish --provider="Woshuo\YunXin\YunXinServiceProvider"
如果你使用 Lumen,将以下代码添加到 bootstrap/app.php
文件中
$app->configure('yunxin');
使用方法
实例化
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);
许可
此包是开源软件,使用 MIT 许可证进行许可。