Get specified user profiles
Retrieve public user profiles in batches by userID using PublicUserInfo.
getUsersInfo() retrieves public profiles for a list of userID values. Use it to display friend candidates and profiles for users who are not friends.
Retrieve public profiles
Call getUsersInfo() with the user IDs to retrieve. Remove empty and duplicate IDs before calling, and keep each request within the supported batch size.
List<String> userIDs = Arrays.asList("user_a", "user_b");
OpenIMClient.getInstance().userInfoManager.getUsersInfo(
new OnBase<List<PublicUserInfo>>() {
@Override
public void onSuccess(List<PublicUserInfo> users) {
// Use users to display public profiles.
}
@Override
public void onError(int code, String error) {
// Handle the error.
}
},
userIDs
);userIDs is the list of user IDs to query. A successful callback returns List<PublicUserInfo>.
Returned fields
| Field | Description |
|---|---|
userID | User ID. |
nickname | Public account nickname. |
faceURL | Public account avatar URL. |
ex | Public account extension string defined by the application. |
createTime | User profile creation time. |
The returned ex contains the user's public extension data. Update the current user's extension data through Update your profile.
Search and add a friend
When the application already has candidate user IDs, call getUsersInfo() to display their public profiles. After the user confirms a target, send a request through Send a friend request.
getUsersInfo() queries public profiles by userID; searching by nickname, phone number, or other fields is outside this API.
Choose data by scenario
Use the corresponding user type for each scenario:
| Scenario | Type |
|---|---|
| User search and stranger profile cards | PublicUserInfo |
| Friend lists, contact pages, and friend remarks | FriendInfo |
| Group member lists, in-group nicknames, and group roles | GroupMembersInfo |
For friend data, see Get specified friend profiles. For group-member data, see Get group members by page.
Next steps
Was this page helpful?