Get user profiles
Batch query public user profile cards by a list of user IDs using getUsersInfo().
Batch query public basic profiles for application users by their user IDs. This is suitable for contact search, stranger profile cards, and user candidate presentations.
Query public profiles
Pass a list of target user IDs to retrieve public profile snapshots in batches. Filter empty strings and duplicate IDs before calling, and keep batch sizes reasonable.
Code example
List<String> userIDs = Arrays.asList("user_a", "user_b");
OpenIMClient.getInstance().userInfoManager.getUsersInfo(
new OnBase<List<PublicUserInfo>>() {
@Override
public void onSuccess(List<PublicUserInfo> users) {
// Render user profiles with users
}
@Override
public void onError(int code, String error) {
// Handle error
}
},
userIDs
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<List<PublicUserInfo>> | Yes | Callback delivering the asynchronous operation result. |
userIDs | List<String> | Yes | List of target user IDs to query. Remove duplicate or empty entries before calling. |
Return value
The successful callback returns a List<PublicUserInfo> containing the matched public user records:
| Field | Description |
|---|---|
userID | Unique global user ID. |
nickname | Public display nickname. |
faceURL | Public avatar URL. |
ex | Custom public extension string. |
createTime | Account registration Unix timestamp. |
Cache and merge returned public profiles using userID as the unique key. To modify the authenticated user's own profile and extension data, see Update the current user profile.
Search and add friends
When your application obtains candidate userID values, query and display their public profile cards first. After user confirmation, initiate a friend request using Send a friend application.
This method performs exact queries by userID. Fuzzy searching by nickname or phone number requires dedicated backend business API support.
Select profile models by context
A single userID resolves to different profile models depending on context:
| Context | Model class |
|---|---|
| User search, candidate lists, stranger cards | PublicUserInfo |
| Friend lists, contact screens, friend remarks | FriendInfo |
| Group member lists, in-group nicknames, group roles | GroupMembersInfo |
For friend profiles, see Get friend profiles. For group member profiles, see Get the group member list.
Next steps
Was this page helpful?