环信及时通讯 Laravel 扩展包

举报
lxw1844912514 发表于 2022/03/27 01:07:45 2022/03/27
【摘要】 laravel-easemob 环信及时通讯 laravel 包开发,用于环信用户、群、聊天室等功能 github 地址   安装 加载包 "link1st/laravel-easemob": "dev-master" 在配置文件中添加 config/app.php ...

laravel-easemob

环信及时通讯 laravel 包开发,用于环信用户、群、聊天室等功能

github 地址

 

安装

加载包

"link1st/laravel-easemob": "dev-master"

在配置文件中添加 config/app.php

    'providers' => [ /** * 添加供应商 */ link1st\Easemob\EasemobServiceProvider::class, ], 'aliases' => [ /** * 添加别名 */ 'Easemob' => link1st\Easemob\Facades\Easemob::class, ],
  

生成配置文件

php artisan vendor:publish

设置环信的参数 config/easemob.php

 

使用


 

获取 token

\Easemob::getToken();


 

开放注册用户

$user = \Easemob::publicRegistration('xiaoming1');

 

授权注册 同一个用户只能注册一次

$user = \Easemob::authorizationRegistration('xiaoming1');

 

批量注册


   
  1. $users = [
  2. ['username'=>'xiaoming2','password'=>1], ['username'=>'xiaoming3','password'=>1], ]; $user = \Easemob::authorizationRegistrations($users);

 

获取用户

$user = \Easemob::getUser('xiaoming1');

 

获取 app 所有的用户

$user = \Easemob::getUserAll(100,'LTgzNDAxMjM3OTprcFJFRUpzdUVlYWh5V1UwQjNSbldR');
  
 

删除用户

$user = \Easemob::delUser('xiaoming1');

 

修改用户密码

$user = \Easemob::editUserPassword('xiaoming2',111);

 

修改昵称

$user = \Easemob::editUserNickName('xiaoming2',11);

 

强制用户下线

$user = \Easemob::disconnect('xiaoming2');

 

添加好友

$user = \Easemob::addFriend('xiaoming2','xiaoming3');

 

删除用户

$user = \Easemob::delFriend('xiaoming2','xiaoming3');

 

显示用户好友

$user = \Easemob::showFriends('xiaoming2');


 

上传文件

\Easemob::uploadFile($file_path);

 

下载文件

\Easemob::downloadFile($uuid, $share_secret);


 

发送文本消息

\Easemob::sendMessageText($users, $target_type = 'users', $message = "", $send_user = 'admin', $ext = []);

 

发送图片消息

\Easemob::sendMessageImg($users, $target_type = 'users', $uuid, $share_secret, $file_name, $width = 480, $height = 720, $send_user = 'admin');

 

发送语音消息

\Easemob::sendMessageAudio($users, $target_type = 'users', $uuid, $share_secret, $file_name, $length = 10, $send_user = 'admin');

 

发送视频消息

\Easemob::sendMessageVideo($users, $target_type = 'users', $video_uuid, $video_share_secret, $video_file_name, $length = 10, $video_length = 58103, $img_uuid, $img_share_secret, $send_user = 'admin');

 

消息透传

\Easemob::sendMessagePNS($users, $target_type = 'users', $action = "", $send_user = 'admin');


 

获取群信息

\Easemob::groups($group_ids);

 

新建群

\Easemob::groupCreate($group_name, $group_description = '描述', $owner_user, $members_users = [], $is_public = true, $max_user = 200, $is_approval = true)

 

修改群信息

\Easemob::groupEdit($group_id, $group_name = "", $group_description = "", $max_user = 0)

 

删除群

\Easemob::groupDel($group_id)

 

获取所有群成员

\Easemob::groupUsers($group_id)

 

添加群成员

\Easemob::groupAddUsers($group_id, $users)

 

删除群成员

\Easemob::groupDelUsers($group_id, $users)

 

获取用户所以参加的群

\Easemob::userToGroups($user)

 

群转让

\Easemob::groupTransfer($group_id, $new_owner_user)


 

查看聊天室详情

\Easemob::room($room_id)

 

创建聊天室

\Easemob::roomCreate($room_name, $owner_name, $room_description = "描述", $max_user = 200, $member_users = [])

 

删除聊天室

\Easemob::roomDel($room_id)

 

修改聊天室信息

\Easemob::roomEdit($room_id, $room_name = "", $room_description = "", $max_user = 0)

 

获取用户参加的聊天室

\Easemob::userToRooms($user)

 

聊天室添加成员

\Easemob::roomAddUsers($room_id, $users)

 

聊天室删除成员

\Easemob::roomDelUsers($room_id, $users)

文章来源: blog.csdn.net,作者:lxw1844912514,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/lxw1844912514/article/details/100028560

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。