/// <summary> /// 查询用户关注明细 /// </summary> /// <param name="mid">目标用户UID</param> /// <param name="pn">页码</param> /// <param name="ps">每页项数</param> /// <param name="order">排序方式</param> /// <returns></returns> public static RelationFollow GetFollowings(long mid, int pn, int ps, FollowingOrder order = FollowingOrder.DEFAULT) { string orderType = ""; if (order == FollowingOrder.ATTENTION) { orderType = "attention"; } string url = $"https://api.bilibili.com/x/relation/followings?vmid={mid}&pn={pn}&ps={ps}&order_type={orderType}"; string referer = "https://www.bilibili.com"; string response = WebClient.RequestWeb(url, referer); try { RelationFollowOrigin relationFollower = JsonConvert.DeserializeObject <RelationFollowOrigin>(response); if (relationFollower == null || relationFollower.Data == null) { return(null); } return(relationFollower.Data); } catch (Exception e) { Utils.Debugging.Console.PrintLine("GetFollowings()发生异常: {0}", e); LogManager.Error("UserRelation", e); return(null); } }
/// <summary> /// 查询用户所有的关注明细 /// </summary> /// <param name="mid">目标用户UID</param> /// <param name="order">排序方式</param> /// <returns></returns> public static List <RelationFollowInfo> GetAllFollowings(long mid, FollowingOrder order = FollowingOrder.DEFAULT) { List <RelationFollowInfo> result = new List <RelationFollowInfo>(); int i = 0; while (true) { i++; int ps = 50; RelationFollow data = GetFollowings(mid, i, ps, order); if (data == null || data.List == null || data.List.Count == 0) { break; } result.AddRange(data.List); } return(result); }
/// <summary> /// 查询所有的关注分组明细 /// </summary> /// <param name="tagId">分组ID</param> /// <param name="order">排序方式</param> /// <returns></returns> public List <FollowingGroupContent> GetAllFollowingGroupContent(int tagId, FollowingOrder order = FollowingOrder.DEFAULT) { List <FollowingGroupContent> result = new List <FollowingGroupContent>(); int i = 0; while (true) { i++; int ps = 50; var data = GetFollowingGroupContent(tagId, i, ps, order); if (data == null || data.Count == 0) { break; } result.AddRange(data); } return(result); }
/// <summary> /// 查询关注分组明细 /// </summary> /// <param name="tagId">分组ID</param> /// <param name="pn">页数</param> /// <param name="ps">每页项数</param> /// <param name="order">排序方式</param> /// <returns></returns> public static List <RelationFollowInfo> GetFollowingGroupContent(int tagId, int pn, int ps, FollowingOrder order = FollowingOrder.DEFAULT) { string orderType = ""; if (order == FollowingOrder.ATTENTION) { orderType = "attention"; } string url = $"https://api.bilibili.com/x/relation/tag?tagid={tagId}&pn={pn}&ps={ps}&order_type={orderType}"; string referer = "https://www.bilibili.com"; string response = WebClient.RequestWeb(url, referer); try { FollowingGroupContent content = JsonConvert.DeserializeObject <FollowingGroupContent>(response); if (content == null || content.Data == null) { return(null); } return(content.Data); } catch (Exception e) { Utils.Debugging.Console.PrintLine("GetFollowingGroupContent()发生异常: {0}", e); LogManager.Error("UserRelation", e); return(null); } }
/// <summary> /// 查询关注分组明细 /// </summary> /// <param name="tagId">分组ID</param> /// <param name="pn">页数</param> /// <param name="ps">每页项数</param> /// <param name="order">排序方式</param> /// <returns></returns> public List <FollowingGroupContent> GetFollowingGroupContent(int tagId, int pn, int ps, FollowingOrder order = FollowingOrder.DEFAULT) { string orderType = ""; if (order == FollowingOrder.ATTENTION) { orderType = "attention"; } string url = $"https://api.bilibili.com/x/relation/tag?tagid={tagId}&pn={pn}&ps={ps}&order_type={orderType}"; string referer = "https://www.bilibili.com"; string response = Utils.RequestWeb(url, referer); try { var content = JsonConvert.DeserializeObject <FollowingGroupContentOrigin>(response); if (content == null || content.Data == null) { return(null); } return(content.Data); } catch (Exception e) { Console.WriteLine("GetFollowingGroupContent()发生异常: {0}", e); return(null); } }