chat.searchCloudUsers(options);
Name | Type | Description |
keywordList | Array | required Keyword list, support up to 5 keywords. |
keywordListMatchType | String | undefined | Keyword List Matching Type: or: relational search ("or" relationship) (default) and: relational search ("and" relationship) |
gender | String | undefined | User gender, if not provided, default search all genders. Gender representation: TencentCloudChat.TYPES.GENDER_FEMALE FemaleTencentCloudChat.TYPES.GENDER_MALE Male |
miniBirthday | Number | undefined | User minimum birthday, e.g., 19900101. |
maxBirthday | Number | undefined | User maximum birthday, when set together with miniBirthday , must be greater than or equal to miniBirthday , such as 20240101. |
cursor | String | undefined | The starting position for each search of cloud users. Do not pass cursor for the first search. For continue search, fill in the value of cursor returned by the last call to the searchCloudUsers API. |
count | Number | undefined | The number of cloud user results per search. The default value is 20, and the maximum value is 100. |
Promise
Name | Type | Description |
totalCount | Number | Total number of users meeting the search condition. |
searchResultList | Array | List of user profiles Profile meeting the search condition, including only avatar avatar , nickname nick , user account userID , gender gender , birthday birthday , and self-signature selfSignature . This can meet the rendering needs of user search result list and does not include custom fields. For detailed user profile, refer to: getUserProfile. |
cursor | String | The cursor needed for calling the search API to continue pulling. |
// Search specified keyword list and birth date range// - Search users with 'test' or 'user' in their profile, and whose birth date is before 20240101let promise = chat.searchCloudUsers({keywordList: ['test', 'user'],maxBirthday: 20240101,});promise.then(function(imResponse) {// User search successfulconst { totalCount, cursor, searchResultList } = imResponse.data;console.log(totalCount); // Total number of users meeting the search conditionconsole.log(cursor); // Starting position for the next cloud search, if not present, indicates search results are fully retrievedconsole.log(searchResultList); // List of users meeting the search condition, return paginated grouping results, maximum 100 per page, count setfor (let i = 0; i < searchResultList.length; i++) {const profileItem = searchResultList[i];const { userID, nick, gender, avatar } = profileItem;console.log(userID); // User IDconsole.log(nick); // User nicknameconsole.log(gender); // User genderconsole.log(avatar); // User avatar}}).catch(function(imError) {console.error(imError); // search user failed});
Was this page helpful?