Follow
功能描述
关注功能允许用户选择他们感兴趣的其他用户,以便及时获取这些用户最新的动态、发布或活动信息,系统可以根据用户的关注列表提供个性化的内容推荐。
粉丝功能是指用户被其他人关注的状态,当用户 A 关注用户 B 时,A 就成为了 B 的粉丝。用户可以在自己的个人资料页面上查看粉丝数量、粉丝列表或者粉丝的资料信息等。
通过关注和粉丝功能,社交应用和网站能够创建一个活跃的、相互连接的用户网络,促进信息的传播和社区的构建。
说明:
功能演示
关注用户
说明:
1. 该接口一次最多支持关注 20 个用户(除了自己之外,其他用户都可以关注)。
2. 每个用户的关注用户数量上限为 5000 人,粉丝用户数量无上限。
接口
chat.followUser(options);
参数
名称 | 类型 | 描述 |
userIDList | Array.<String> | 用户 userID 列表,一次最多支持关注 20 个用户。 |
返回值
Promise
示例
let promise = chat.followUser(['user1', 'user2']); promise.then(function(imResponse) { console.log(imResponse.data); // 关注的结果信息 }).catch(function(imError) { console.warn('followUser error:', imError); });
取消关注用户
说明:
1. 该接口一次最多支持取消关注 20 个用户。
接口
chat.unfollowUser(options);
参数
名称 | 类型 | 描述 |
userIDList | Array.<String> | 用户 userID 列表,一次最多支持取消关注 20 个用户。 |
返回值
Promise
示例
let promise = chat.unfollowUser(['user1', 'user2']); promise.then(function(imResponse) { console.log(imResponse.data); // 取消关注的结果信息 }).catch(function(imError) { console.warn('followUser error:', imError); });
获取我的粉丝列表
说明:
该接口每次最多返回 500 个用户。
接口
chat.getMyFollowersList(nextCursor);
参数
名称 | 类型 | 描述 |
nextCursor | String | undefined | 分页拉取起始位置,首页拉取默认为空,可不传,获取成功时 nextCursor 不为 '',需要分页,可以传入该值再次拉取,直至 nextCursor 返回为 ''。 |
返回值
Promise
示例
let promise = chat.getMyFollowersList(nextCursor); promise.then(function(imResponse) { const { resultList, nextCursor = '' } = imResponse.data; // ressultList - 我的粉丝列表 // nextCursor - 分页续拉的标识 if (nextCursor != '') { // 需要续拉 } }).catch(function(imError) { console.warn('getMyFollowersList error:', imError); });
获取我的关注列表
说明:
该接口每次最多返回 500 个用户。
接口
chat.getMyFollowingList(nextCursor);
参数
名称 | 类型 | 描述 |
nextCursor | String | undefined | 分页拉取起始位置,首页拉取默认为空,可不传,获取成功时 nextCursor 不为 '',需要分页,可以传入该值再次拉取,直至 nextCursor 返回为 ''。 |
返回值
Promise
示例
let promise = chat.getMyFollowingList(); promise.then(function(imResponse) { const { resultList, nextCursor = '' } = imResponse.data; // ressultList - 我的粉丝列表 // nextCursor - 分页续拉的标识 if (nextCursor != '') { // 需要续拉 } }).catch(function(imError) { console.warn('getMyFollowingList error:', imError); });
获取互关列表
接口
chat.getMutualFollowersList(nextCursor);
参数
名称 | 类型 | 描述 |
nextCursor | String | undefined | 分页拉取起始位置,首页拉取默认为空,可不传,获取成功时 nextCursor 不为 '',需要分页,可以传入该值再次拉取,直至 nextCursor 返回为 ''。 |
返回值
Promise
示例
let promise = chat.getMutualFollowersList();promise.then(function(imResponse) {const { resultList, nextCursor = '' } = imResponse.data;// ressultList - 互关列表// nextCursor - 分页续拉的标识if (nextCursor != '') {// 需要续拉}}).catch(function(imError) {console.warn('getMutualFollowersList error:', imError);});
获取指定用户的 关注/粉丝/互关 数量信息
接口
chat.getUserFollowInfo(userIDList);
参数
名称 | 类型 | 描述 |
userIDList | Array.<String> | 用户 userID 列表,不传 userIDList 表示获取自己的 关注/粉丝/互关 数量信息 |
返回值
Promise
示例
// 获取自己的 关注/粉丝/互关 数量信息let promise = chat.getUserFollowInfo();promise.then(function(imResponse) {console.log(imResponse.data); // 获取成功}).catch(function(imError) {console.warn('getUserFollowInfo error:', imError);});
// 获取指定用户的 关注/粉丝/互关 数量信息 let promise = chat.getUserFollowInfo(['user1', 'user2']); promise.then(function(imResponse) { console.log(imResponse.data); // 获取成功 }).catch(function(imError) { console.warn('getUserFollowInfo error:', imError); });
检查指定用户的关注关系
接口
chat.checkFollowType(userIDList);
参数
名称 | 类型 | 描述 |
userIDList | Array.<String> | 待检查的用户 userID 列表,单次请求最多支持 100 个 userID。 |
返回值
Promise
示例
let promise = chat.checkFollowType(['user1', 'user2']);promise.then(function(imResponse) {console.log(imResponse.data); // 校验结果列表imResponse.data.forEach((item) => {// item.userID - 用户 userID// item.followType - 关注关系(0 - 没有关系, 1 - 粉丝, 2 - 关注, 3 - 互关)});}).catch(function(imError) {console.warn('checkFollowType error:', imError);});