使用API 3.0获取YouTube视频的评论或顶数 [英] Get comment or likes count for YouTube video using API 3.0
本文介绍了使用API 3.0获取YouTube视频的评论或顶数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得具有特定YouTube ID的视频的评论和/或喜欢的次数。
我正在使用YouTube API v3.0。
I want to get number of comments and/or likes for video with specific YouTube ID. I am using YouTube API v3.0.
我正在搜索API文档,找不到合适的方法。
I was searching through API documentation and can't find appropriate method.
推荐答案
更好地查看了Google API文档在这里,我发现我可以使用Videos.List API的 statistics部分参数来获取所需的内容。
After having better look at Google API documentation here, I have found that I can use "statistics" part parameter of Videos.List API in order to get what I want.
确切的HTTP发布请求应该是(注意 part = statistics 参数):
Exact HTTP post request should be (notice part=statistics parameter):
GET https://www.googleapis.com/youtube/v3/videos?part=statistics&id=sTPtBvcYkO8&key={YOUR_API_KEY}
响应为:
{
"kind": "youtube#videoListResponse",
"etag": "\"kjEFmP90GvrCl8BObMQtGoRfgaQ/XN5YXMZGQaruwTWTekZu7fQthdY\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"kjEFmP90GvrCl8BObMQtGoRfgaQ/QbzZs_aBNpzkZJxTVM7YgQeEY3g\"",
"id": "sTPtBvcYkO8",
"statistics": {
"viewCount": "3215321",
"likeCount": "17003",
"dislikeCount": "263",
"favoriteCount": "0",
"commentCount": "621"
}
}
]
}
这篇关于使用API 3.0获取YouTube视频的评论或顶数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文