YouTube commentThreads 将评论回复限制为 JSON 数据中的 5 个结果?
YouTube commentThreads limiting comment replies to 5 results in JSON data?
我构建了一个 PHP 脚本来提取所有评论(通过迭代所有结果页面)和他们的回复。它工作正常,除了回复似乎限制在 5 个结果。
items->replies->comments
...这在 JSON 数据中只有 5 个结果,即使 items->snippet->totalReplyCount
高于 5。
这是我正在使用的电话:
https://www.googleapis.com/youtube/v3/commentThreads?key={KEY}&part=snippet,replies&maxResults=100&videoId={VIDEO}
谢谢!
根据the docs(以下强调是我的):
A commentThread
resource contains information about a YouTube comment thread, which comprises a top-level comment and replies, if any exist, to that comment. A commentThread
resource can represent comments about either a video or a channel.
Both the top-level comment and the replies are actually comment
resources nested inside the commentThread
resource. The commentThread
resource does not necessarily contain all replies to a comment, and you need to use the Comments.list
method if you want to retrieve all replies for a particular comment. Also note that some comments do not have replies.
因此,如果您想获取所有顶级评论及其每个相关回复,您必须在两个循环中组合两个端点 CommentThreads.list
和 Comments.list
:
- 获取所有置顶评论;
- 对于每个这样的顶级评论,获取其所有附加回复。
组合这些循环的方式取决于您(注意:这两个 API 端点都提供分页结果集)。
我构建了一个 PHP 脚本来提取所有评论(通过迭代所有结果页面)和他们的回复。它工作正常,除了回复似乎限制在 5 个结果。
items->replies->comments
...这在 JSON 数据中只有 5 个结果,即使 items->snippet->totalReplyCount
高于 5。
这是我正在使用的电话:
https://www.googleapis.com/youtube/v3/commentThreads?key={KEY}&part=snippet,replies&maxResults=100&videoId={VIDEO}
谢谢!
根据the docs(以下强调是我的):
A
commentThread
resource contains information about a YouTube comment thread, which comprises a top-level comment and replies, if any exist, to that comment. AcommentThread
resource can represent comments about either a video or a channel.Both the top-level comment and the replies are actually
comment
resources nested inside thecommentThread
resource. ThecommentThread
resource does not necessarily contain all replies to a comment, and you need to use theComments.list
method if you want to retrieve all replies for a particular comment. Also note that some comments do not have replies.
因此,如果您想获取所有顶级评论及其每个相关回复,您必须在两个循环中组合两个端点 CommentThreads.list
和 Comments.list
:
- 获取所有置顶评论;
- 对于每个这样的顶级评论,获取其所有附加回复。
组合这些循环的方式取决于您(注意:这两个 API 端点都提供分页结果集)。