Youtube API v3 获取评论

6

I am using Comments: list method

Request

https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=ay4MKe1u7Ec&key=`{MY_KEY}`

我使用API获取评论,返回结果如下:

{
 "kind": "youtube#commentListResponse",
 "etag": "\"xmg9xJZuZD438sF4hb-VcBBREXc/pGLBhpjR05yQoJV31WoAx2PEFVw\"",
 "items": []
}

可能是因为父ID ay4MKe1u7Ec 没有结果。 - Linda Lawton - DaImTo
那么你的问题到底是什么? - almightyGOSU
检查YouTube上的视频是否有评论?也许那个视频没有评论。 - user4657588
1个回答

18

当你已经知道评论的ID时,comments->list方法仅用于获取有关评论的其他信息...或者在您的URL的情况下,如果您尝试获取回复父ID的评论的更多详细信息。换句话说,您无法将videoID放入comments->list方法中。

您需要的是commentThreads->list端点:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=ay4MKe1u7Ec&key={YOUR_API_KEY}

这将为您提供所有带有其ID的评论... 您可以获取这些ID,然后通过comments->list端点运行它们以获取更详细的信息。


1
commentThreads->list 最多可以返回 100 条评论。我在响应中看到了 nextPageToken。如何遍历并检索所有评论? - Jaison

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接