PHPSDK
Public 成员函数 | 所有成员列表
Easemob\Group类 参考

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 用来管理群组

成员函数说明

◆ addGroupAdmin()

Easemob\Group::addGroupAdmin (   $groupId,
  $newadmin 
)

添加群管理员

将一个群成员角色权限提升为群管理员。

参数
string$groupId群组 ID
string$newadmin添加的新管理员用户 ID
返回
boolean|array 成功或者错误

◆ addGroupMember()

Easemob\Group::addGroupMember (   $groupId,
  $username 
)

添加单个群组成员

一次给群添加一个成员,不能重复添加同一个成员。如果用户已经是群成员,将添加失败,并返回错误。

参数
string$groupId群组 ID
string$username环信用户 ID
返回
boolean|array 成功或者错误

◆ addGroupMembers()

Easemob\Group::addGroupMembers (   $groupId,
  $usernames 
)

批量添加群组成员

为群组添加多个成员,一次最多可以添加 60 位成员。如果所有用户均已是群成员,将添加失败,并返回错误。

参数
string$groupId群组 ID
array$usernames环信用户 ID 数组
返回
boolean|array 成功或者错误

◆ createPrivateGroup()

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 字符。
返回
string|array 群组 id 或者错误

◆ createPublicGroup()

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 字符。
返回
string|array 群组 id 或者错误

◆ deleteGroupShareFile()

Easemob\Group::deleteGroupShareFile (   $groupId,
  $fileId 
)

删除群组共享文件

根据指定的群组 ID 与 file_id 删除群组共享文件,file_id 通过 getGroupShareFiles($groupId, $pageSize = 10, $pageNum = 1) 获取。

参数
string$groupId群组 ID
string$fileId群组共享文件 id
返回
boolean|array 成功或者错误

◆ destroyGroup()

Easemob\Group::destroyGroup (   $groupId)

删除群组

参数
string$groupId群组 id
返回
boolean|array 成功或者错误

◆ downloadGroupShareFile()

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
返回
int|array 文件大小或者错误

◆ getGroup()

Easemob\Group::getGroup (   $groupId)

获取群组详情

可以获取一个或多个群组的详情。当获取多个群组的详情时,返回所有存在的群组的详情;对于不存在的群组,返回 “group id doesn’t exist”。

参数
string$groupId群组 ID,可以以逗号分割,同时传递多个群组 ID
返回
array 群组信息或者错误

◆ getGroupAnnouncement()

Easemob\Group::getGroupAnnouncement (   $groupId)

获取群组公告

获取指定群组 ID 的群组公告。

参数
string$groupId群组 id
返回
array 公告信息或者错误

◆ getGroupShareFiles()

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当前页码。该参数仅适用于分页获取方法。
返回
array 群组文件信息或者错误

◆ listAllGroupMembers()

Easemob\Group::listAllGroupMembers (   $groupId)

获取群组所有成员

参数
string$groupId群组 ID
返回
array 群组成员信息或者错误

◆ listAllGroups()

Easemob\Group::listAllGroups ( )

获取 App 中所有的群组

返回
array 群组列表信息或者错误

◆ listAllGroupsUserJoined()

Easemob\Group::listAllGroupsUserJoined (   $username)

brief 获取单个用户加入的所有群组

参数
string$username用户名
返回
array 群组信息或者错误

◆ listGroupAdmins()

Easemob\Group::listGroupAdmins (   $groupId)

获取群管理员列表

参数
string$groupId群组 ID
返回
array 群管理员信息或者错误

◆ listGroupMembers()

Easemob\Group::listGroupMembers (   $groupId,
  $pageSize = 10,
  $pageNum = 1 
)

分页获取群组成员

参数
string$groupId群组 ID
int$pageSize每页成员数量,默认值为 10,最大为 100。
int$pageNum当前页码。默认值为 1。
返回
array 群组成员信息或者错误

◆ listGroups()

Easemob\Group::listGroups (   $limit = 10,
  $cursor = '' 
)

获取 App 中所有的群组(可分页)

参数
int$limit一次获取的群组数量,默认获取 10 条。
string$cursor分页使用,传入游标后便从游标起始的地方进行查询,类似于数据库 limit 1,5 中 1 的作用,可以理解为页码。
返回
array 群组列表信息或者错误

◆ listGroupsUserJoined()

Easemob\Group::listGroupsUserJoined (   $username,
  $pageSize = 10,
  $pageNum = 1 
)

分页获取单个用户加入的所有群组

参数
string$username用户名
int$pageSize每页获取的群组数量。该参数仅适用于分页获取方法。默认取 10 条。
int$pageNum当前页码。该参数仅适用于分页获取方法。
返回
array 群组信息或者错误

◆ removeGroupAdmin()

Easemob\Group::removeGroupAdmin (   $groupId,
  $oldadmin 
)

移除群管理员

将用户的角色从群管理员降为群普通成员。

参数
string$groupId群组 ID
string$oldadmin移除的管理员用户 ID
返回
boolean|array 成功或者错误

◆ removeGroupMember()

Easemob\Group::removeGroupMember (   $groupId,
  $username 
)

移除单个群组成员

从群中移除某个成员。如果被移除用户不是群成员,将移除失败,并返回错误。

参数
string$groupId群组 ID
string$username环信用户 ID
返回
boolean|array 成功或者错误

◆ removeGroupMembers()

Easemob\Group::removeGroupMembers (   $groupId,
  $usernames 
)

批量移除群组成员

移除群成员,用户名之间用英文逗号分隔。建议一次最多移除 60 个群成员。如果所有被移除用户均不是群成员,将移除失败,并返回错误。

参数
string$groupId群组 ID
array$username环信用户 ID 数组
返回
boolean|array 成功或者错误

◆ updateGroup()

Easemob\Group::updateGroup (   $data)

修改群组信息

修改成功的数据行会返回 true,失败为 false。请求 body 只接收 groupname、description、maxusers、membersonly、allowinvites、custom 六个属性,传不存在的字段,或者不能修改的字段会抛异常。

参数
array$data群组信息
  • groupname string 类型,群组名称,修改时值不能包含斜杠(“/”),最大长度为 128 字符。
  • description string 类型,群组描述,修改时值不能包含斜杠(“/”),最大长度为 512 字符。
  • maxusers int 类型,群组成员最大数(包括群主),值为数值类型。
  • membersonly string 类型,加入群组是否需要群主或者群管理员审批:true:是;false:否。
  • allowinvites string 类型,是否允许群成员邀请别人加入此群:true:允许群成员邀请人加入此群;false:只有群主才可以往群里加人。
  • custom string 类型,群组扩展信息,例如可以给群组添加业务相关的标记,不要超过 1,024 字符。
返回
boolean|array 成功或者错误

◆ updateGroupAnnouncement()

Easemob\Group::updateGroupAnnouncement (   $groupId,
  $announcement 
)

修改群组公告

修改指定群组 ID 的群组公告,注意群组公告的内容不能超过 512 个字符。

参数
string$groupId群组 ID
string$announcement群组公告内容
返回
boolean|array 成功或者错误

◆ updateGroupOwner()

Easemob\Group::updateGroupOwner (   $groupId,
  $newowner 
)

转让群组

修改群主为同一群组中的其他成员。

参数
string$groupId群组 ID
string$newowner群组的新管理员用户 ID
返回
boolean|array 成功或者错误

◆ uploadGroupShareFile()

Easemob\Group::uploadGroupShareFile (   $groupId,
  $fileName 
)

上传群组共享文件

上传指定群组 ID 的群组共享文件。注意上传的文件大小不能超过 10 MB。

参数
string$groupId群组 ID
string$fileName上传的文件路径
返回
array 上传的文件信息或者错误