|
PHPSDK
|
Public 成员函数 | |
| listGroups ($limit=10, $cursor='') | |
| 获取 App 中所有的群组(可分页) 更多... | |
| listAllGroups () | |
| 获取 App 中所有的群组 更多... | |
| listGroupsUserJoined ($username, $pageSize=10, $pageNum=1) | |
| 分页获取单个用户加入的所有群组 更多... | |
| listAllGroupsUserJoined ($username) | |
| getGroup ($groupId) | |
| 获取群组详情 更多... | |
| createPublicGroup ($owner, $groupname, $desc, $members=array(), $maxusers=200, $members_only=true, $custom='') | |
| 创建公开群 更多... | |
| createPrivateGroup ($owner, $groupname, $desc, $members=array(), $maxusers=200, $allowinvites=false, $custom='') | |
| 创建私有群 更多... | |
| updateGroup ($data) | |
| 修改群组信息 更多... | |
| destroyGroup ($groupId) | |
| 删除群组 更多... | |
| getGroupAnnouncement ($groupId) | |
| 获取群组公告 更多... | |
| updateGroupAnnouncement ($groupId, $announcement) | |
| 修改群组公告 更多... | |
| getGroupShareFiles ($groupId, $pageSize=10, $pageNum=1) | |
| 获取群组共享文件 更多... | |
| uploadGroupShareFile ($groupId, $fileName) | |
| 上传群组共享文件 更多... | |
| downloadGroupShareFile ($fileName, $groupId, $fileId) | |
| 下载群组共享文件 更多... | |
| deleteGroupShareFile ($groupId, $fileId) | |
| 删除群组共享文件 更多... | |
| listGroupMembers ($groupId, $pageSize=10, $pageNum=1) | |
| 分页获取群组成员 更多... | |
| listAllGroupMembers ($groupId) | |
| 获取群组所有成员 更多... | |
| addGroupMember ($groupId, $username) | |
| 添加单个群组成员 更多... | |
| addGroupMembers ($groupId, $usernames) | |
| 批量添加群组成员 更多... | |
| removeGroupMember ($groupId, $username) | |
| 移除单个群组成员 更多... | |
| removeGroupMembers ($groupId, $usernames) | |
| 批量移除群组成员 更多... | |
| listGroupAdmins ($groupId) | |
| 获取群管理员列表 更多... | |
| addGroupAdmin ($groupId, $newadmin) | |
| 添加群管理员 更多... | |
| removeGroupAdmin ($groupId, $oldadmin) | |
| 移除群管理员 更多... | |
| updateGroupOwner ($groupId, $newowner) | |
| 转让群组 更多... | |
Group 用来管理群组
| Easemob\Group::addGroupAdmin | ( | $groupId, | |
| $newadmin | |||
| ) |
添加群管理员
将一个群成员角色权限提升为群管理员。
| string | $groupId | 群组 ID |
| string | $newadmin | 添加的新管理员用户 ID |
| Easemob\Group::addGroupMember | ( | $groupId, | |
| $username | |||
| ) |
添加单个群组成员
一次给群添加一个成员,不能重复添加同一个成员。如果用户已经是群成员,将添加失败,并返回错误。
| string | $groupId | 群组 ID |
| string | $username | 环信用户 ID |
| Easemob\Group::addGroupMembers | ( | $groupId, | |
| $usernames | |||
| ) |
批量添加群组成员
为群组添加多个成员,一次最多可以添加 60 位成员。如果所有用户均已是群成员,将添加失败,并返回错误。
| string | $groupId | 群组 ID |
| array | $usernames | 环信用户 ID 数组 |
| Easemob\Group::createPrivateGroup | ( | $owner, | |
| $groupname, | |||
| $desc, | |||
$members = array(), |
|||
$maxusers = 200, |
|||
$allowinvites = false, |
|||
$custom = '' |
|||
| ) |
创建私有群
创建一个私有的群组,并设置群主、群组名称、群组描述、群成员、群成员最大人数(包括群主)、是否允许群成员邀请别人加入此群、群组扩展信息。
| string | $owner | 群组管理员的用户名 |
| string | $groupname | 群组名称,最大长度为 128 字符。 |
| string | $desc | 群组描述,最大长度为 512 字符。 |
| array | $members | 群组成员,此属性为非必需,但是如果加此项,数组元素至少一个,不能超过 100 个。(注:群主 user1 不需要写入到 members 里面) |
| int | $maxusers | 群组最大成员数(包括群主),值为数值类型,默认值 200,具体上限请参考 环信即时通讯云控制台。 |
| boolean | $allowinvites | 是否允许群成员邀请别人加入此群:true:允许群成员邀请人加入此群;false:只有群主或者管理员才可以往群里加人。 |
| string | $custom | 群组扩展信息,例如可以给群组添加业务相关的标记,不要超过 1024 字符。 |
| Easemob\Group::createPublicGroup | ( | $owner, | |
| $groupname, | |||
| $desc, | |||
$members = array(), |
|||
$maxusers = 200, |
|||
$members_only = true, |
|||
$custom = '' |
|||
| ) |
创建公开群
创建一个公开的群组,并设置群主、群组名称、群组描述、群成员、群成员最大人数(包括群主)、加入群是否需要批准、群组扩展信息。
| string | $owner | 群组管理员的用户名 |
| string | $groupname | 群组名称,最大长度为 128 字符。 |
| string | $desc | 群组描述,最大长度为 512 字符。 |
| array | $members | 群组成员,此属性为非必需,但是如果加此项,数组元素至少一个,不能超过 100 个。(注:群主 user1 不需要写入到 members 里面) |
| int | $maxusers | 群组最大成员数(包括群主),值为数值类型,默认值 200,具体上限请参考 环信即时通讯云控制台。 |
| boolean | $members_only | 用户申请入群是否需要群主或者群管理员审批,默认是 false。true:是;false:否。 |
| string | $custom | 群组扩展信息,例如可以给群组添加业务相关的标记,不要超过 1024 字符。 |
| Easemob\Group::deleteGroupShareFile | ( | $groupId, | |
| $fileId | |||
| ) |
删除群组共享文件
根据指定的群组 ID 与 file_id 删除群组共享文件,file_id 通过 getGroupShareFiles($groupId, $pageSize = 10, $pageNum = 1) 获取。
| string | $groupId | 群组 ID |
| string | $fileId | 群组共享文件 id |
| Easemob\Group::destroyGroup | ( | $groupId | ) |
删除群组
| string | $groupId | 群组 id |
| Easemob\Group::downloadGroupShareFile | ( | $fileName, | |
| $groupId, | |||
| $fileId | |||
| ) |
下载群组共享文件
根据指定的群组 ID 与 file_id 下载群组共享文件,file_id 通过 getGroupShareFiles($groupId, $pageSize = 10, $pageNum = 1) 获取。
| string | $fileName | 要下载的文件路径 |
| string | $groupId | 群组 ID |
| string | $fileId | 群组共享文件 id |
| Easemob\Group::getGroup | ( | $groupId | ) |
获取群组详情
可以获取一个或多个群组的详情。当获取多个群组的详情时,返回所有存在的群组的详情;对于不存在的群组,返回 “group id doesn’t exist”。
| string | $groupId | 群组 ID,可以以逗号分割,同时传递多个群组 ID |
| Easemob\Group::getGroupAnnouncement | ( | $groupId | ) |
获取群组公告
获取指定群组 ID 的群组公告。
| string | $groupId | 群组 id |
| Easemob\Group::getGroupShareFiles | ( | $groupId, | |
$pageSize = 10, |
|||
$pageNum = 1 |
|||
| ) |
获取群组共享文件
分页获取指定群组 ID 的群组共享文件,之后可以根据 response 中返回的 file_id,file_id 是群组共享文件的唯一标识,调用 downloadGroupShareFile($fileName, $groupId, $fileId) 下载文件,或调用 deleteGroupShareFile($groupId, $fileId) 删除文件。
| string | $groupId | 群组 ID |
| int | $pageSize | 每页获取的群组数量。该参数仅适用于分页获取方法。默认取 10 条。 |
| int | $pageNum | 当前页码。该参数仅适用于分页获取方法。 |
| Easemob\Group::listAllGroupMembers | ( | $groupId | ) |
获取群组所有成员
| string | $groupId | 群组 ID |
| Easemob\Group::listAllGroups | ( | ) |
获取 App 中所有的群组
| Easemob\Group::listAllGroupsUserJoined | ( | $username | ) |
brief 获取单个用户加入的所有群组
| string | $username | 用户名 |
| Easemob\Group::listGroupAdmins | ( | $groupId | ) |
获取群管理员列表
| string | $groupId | 群组 ID |
| Easemob\Group::listGroupMembers | ( | $groupId, | |
$pageSize = 10, |
|||
$pageNum = 1 |
|||
| ) |
分页获取群组成员
| string | $groupId | 群组 ID |
| int | $pageSize | 每页成员数量,默认值为 10,最大为 100。 |
| int | $pageNum | 当前页码。默认值为 1。 |
| Easemob\Group::listGroups | ( | $limit = 10, |
|
$cursor = '' |
|||
| ) |
获取 App 中所有的群组(可分页)
| int | $limit | 一次获取的群组数量,默认获取 10 条。 |
| string | $cursor | 分页使用,传入游标后便从游标起始的地方进行查询,类似于数据库 limit 1,5 中 1 的作用,可以理解为页码。 |
| Easemob\Group::listGroupsUserJoined | ( | $username, | |
$pageSize = 10, |
|||
$pageNum = 1 |
|||
| ) |
分页获取单个用户加入的所有群组
| string | $username | 用户名 |
| int | $pageSize | 每页获取的群组数量。该参数仅适用于分页获取方法。默认取 10 条。 |
| int | $pageNum | 当前页码。该参数仅适用于分页获取方法。 |
| Easemob\Group::removeGroupAdmin | ( | $groupId, | |
| $oldadmin | |||
| ) |
移除群管理员
将用户的角色从群管理员降为群普通成员。
| string | $groupId | 群组 ID |
| string | $oldadmin | 移除的管理员用户 ID |
| Easemob\Group::removeGroupMember | ( | $groupId, | |
| $username | |||
| ) |
移除单个群组成员
从群中移除某个成员。如果被移除用户不是群成员,将移除失败,并返回错误。
| string | $groupId | 群组 ID |
| string | $username | 环信用户 ID |
| Easemob\Group::removeGroupMembers | ( | $groupId, | |
| $usernames | |||
| ) |
批量移除群组成员
移除群成员,用户名之间用英文逗号分隔。建议一次最多移除 60 个群成员。如果所有被移除用户均不是群成员,将移除失败,并返回错误。
| string | $groupId | 群组 ID |
| array | $username | 环信用户 ID 数组 |
| Easemob\Group::updateGroup | ( | $data | ) |
修改群组信息
修改成功的数据行会返回 true,失败为 false。请求 body 只接收 groupname、description、maxusers、membersonly、allowinvites、custom 六个属性,传不存在的字段,或者不能修改的字段会抛异常。
| array | $data | 群组信息
|
| Easemob\Group::updateGroupAnnouncement | ( | $groupId, | |
| $announcement | |||
| ) |
修改群组公告
修改指定群组 ID 的群组公告,注意群组公告的内容不能超过 512 个字符。
| string | $groupId | 群组 ID |
| string | $announcement | 群组公告内容 |
| Easemob\Group::updateGroupOwner | ( | $groupId, | |
| $newowner | |||
| ) |
转让群组
修改群主为同一群组中的其他成员。
| string | $groupId | 群组 ID |
| string | $newowner | 群组的新管理员用户 ID |
| Easemob\Group::uploadGroupShareFile | ( | $groupId, | |
| $fileName | |||
| ) |
上传群组共享文件
上传指定群组 ID 的群组共享文件。注意上传的文件大小不能超过 10 MB。
| string | $groupId | 群组 ID |
| string | $fileName | 上传的文件路径 |