产品动态
公告
chat.searchCloudGroupMembers(options);
Name | Type | Description |
keywordList | Array | required关键字列表,最多支持 5 个。 |
keywordListMatchType | String | undefined | 关键字列表匹配类型: or:“或”关系搜索(默认) and:“与”关系搜索 |
groupTypeList | Array | undefined | 不传入时默认搜索所有类型群成员(不支持直播群 TencentCloudChat.TYPES.GRP_AVCHATROOM 类型的搜索)。群类型表示: TencentCloudChat.TYPES.GRP_WORK 好友工作群TencentCloudChat.TYPES.GRP_PUBLIC 陌生人社交群TencentCloudChat.TYPES.GRP_MEETING 临时会议群TencentCloudChat.TYPES.GRP_COMMUNITY 社群 |
groupIDList | Array | undefined | 搜索指定群 ID 列表,不传入时默认搜索所有群组 |
cursor | String | undefined | 每次搜索云端群成员的起始位置。第一次搜索时不要传入 cursor,继续搜索时填入上次调用 searchCloudGroupMembers 接口返回的 cursor 的值。 |
count | Number | undefined | 每次搜索云端群成员结果的数量,默认值为 20, 最大值为100。 |
PromiseName | Type | Description |
totalCount | Number | 满足搜索条件的群成员总数。 |
searchResultList | Array | 满足搜索条件的群成员列表,按照群组ID groupID 进行分组返回。 |
cursor | String | 调用搜索接口续拉时需要填的游标。 |
searchResultList 是个列表,内含搜索结果对象,参数说明如下:Name | Type | Description |
groupInfo | Object | 群组资料信息,包含以下群组资料: groupID 群组 ID。name 群组名称。type 群组类型。avatar 群组头像。 |
memberList | Array | 当前群组内满足搜索条件的群成员列表。列表中每个群成员包含以下信息: userID 群成员用户 ID。nick 群成员用户昵称。nameCard 群名片。 |
// 搜索指定关键字列表和群ID列表// - 搜索当前加入群组的群成员里出现 'test' 或 'user',且群ID为 'group1' 或 'group2' 的群的群成员let promise = chat.searchCloudGroupMembers({keywordList: ['test', 'user'],groupIDList: ['group1', 'group2'],});promise.then(function(imResponse) {// 搜索群成员成功const { totalCount, cursor, searchResultList } = imResponse.data;console.log(totalCount); // 满足搜索条件的群成员总数量console.log(cursor); // 下一次云端搜索的起始位置, 如果没有表示搜索结果拉取完成console.log(searchResultList); // 满足搜索条件的群成员列表,分页返回分组结果,每页最大返回 100 条,根据传入 count 设定for (let i = 0; i < searchResultList.length; i++) {const searchResultItem = searchResultList[i];const { groupInfo, memberList } = searchResultItem;const { groupID, name, type, avatar } = groupInfo;// 群 groupID / 群名称 / 群类型 / 群头像console.log(groupID, name, type, avatar);console.log(memberList); // 该群中满足条件成员列表for (let i = 0; i < memberList.length; i++) {const memberItem = memberList[i];const { userID, nick, nameCard } = memberItem;console.log(userID); // 群成员用户 IDconsole.log(nick); // 群成员用户昵称console.log(nameCard); // 群名片}}}).catch(function(imError) {console.error(imError); // 搜索群成员失败});
文档反馈