使用 Google YouTube V3 API 未检索到回复或未检索到所有评论 [英] No replies or not all comments retrieved using Google YouTube V3 API
问题描述
我正在尝试检索包含所有回复的视频的所有评论,但是,使用 Test It 界面(或 Java 库)我无法检索所有评论 - 当我失败时,我有以下两个示例:
示例 1
示例视频和评论是
并注意 "totalReplyCount": 2,
行.
但是,当我尝试使用 parentId 获取所有回复时:
GET https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z12ei1s5gs2mc303523qsdigcxmphhlrd04&fields=etag%2CeventId%2Citems%2Ckind%2CvisitPage2%2tokenPagination={YOUR_API_KEY}
我收到一个空回复:
备注
我已阅读
但是,如果我不通过 ID 指定评论线程并指定我想要视频的所有评论线程:
GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&videoId=xCLy2DZdXhY&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CtokenPagination%2C;key={YOUR_API_KEY}
然后瞧 - 评论线程现在有这两个回复:
为什么我现在收到回复,而不是在我通过其 parentId 指定回复或通过其 ID 指定评论线程时收到回复?
此外,如果我使用其中一个回复的(奇怪的)id 并尝试获取带有此回复的评论,我将收到空回复:
GET https://www.googleapis.com/youtube/v3/comments?part=snippet&id=z12ei1s5gs2mc303523qsdigcxmphhlrd04.1443381718685326&fields=etag%2CeventId%%Cagination%Camp;id=z12ei1s5gs2mc303523;key={YOUR_API_KEY}
示例 2
这个问题有点不同.我有一个视频
回复中缺少的评论之一是
此外,当我尝试获取此评论的回复(应该有 1 个回复)时,我收到了一个空回复:
GET https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k&fields=etag%2CeventId%2Citems%2Ckind%2Citems%2Ckind%2Cenpage%PvisitToken&parentId=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k&fields={YOUR_API_KEY}
备注
对于这两个示例,评论数量都小于页面大小.对于这个简单的例子,我跳过了分页,只选择了一些评论的例子,在实际应用中我使用了分页,但我没有得到更多的结果.
我不太明白 YouTube 和 G+ 是如何集成在一起的,因此这可能是问题所在,但是,我总是只使用 youtube 访问这些视频,而不是查看用户的 G+ 页面,因此我会说这不应该是这种情况.
关于 SO 的类似问题:
我怎么看所有关于 Youtube API 的评论?这是关于 V2 API,因此对我没有用.
Youtube Data API v3:commentThread 调用不会对某些评论线程进行回复 这个问题非常相似,并提出了类似的问题,但是,恰恰相反 - 作者没有收到使用 commentThread 的所有回复回复(同意文档),但是,建议的解决方案是使用 comments.list改为调用并为 parentId 指定 commentThread 的 ID."- 这对我不起作用.
YouTube 数据 API v3 评论线程差异作者忘记了分页.
YouTube 数据 API v3- 评论线程请求不会返回所有评论 类似的问题,但没有任何答案.
当我通过 HTTP 请求执行以下操作时:
https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z12ei1s5gs2mc303523qsdigcxmphhlrd04&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2tokenpageId&parentId=z12ei1s5gs2mc303523{YOUR_API_KEY}
我收到以下回复:
items": [{"kind": "youtube#comment","etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/aOipn7OKd9ibVua9TWdtD2vJJgI\"","id": "z12ei1s5gs2mc303523qsdigcxmphhlrd04.1443381718685326",片段":{"textDisplay": "JM","parentId": "z12ei1s5gs2mc303523qsdigcxmphhlrd04","authorDisplayName": "亚洲价格","authorProfileImageUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50","authorChannelUrl": "http://www.youtube.com/channel/UCtUuxM3_g2hWA7qr17d85RQ",作者频道ID":{值":UCtUuxM3_g2hWA7qr17d85RQ"},"authorGoogleplusProfileUrl": "https://plus.google.com/100662746258967935686",canRate":假,"viewerRating": "无","likeCount": 0,"publishedAt": "2015-09-27T19:21:58.685Z","updatedAt": "2015-09-27T19:21:58.685Z"}},{"kind": "youtube#comment","etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/NtowtHGdhytzw9YY9RxUopEgoTA\"","id": "z12ei1s5gs2mc303523qsdigcxmphhlrd04.1443365800258222",片段":{"文本显示": "0","parentId": "z12ei1s5gs2mc303523qsdigcxmphhlrd04","authorDisplayName": "FAY Fay","authorProfileImageUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50","authorChannelUrl": "http://www.youtube.com/channel/UC5b4dTxK4ae_roaMWMYpglQ",作者频道ID":{值":UC5b4dTxK4ae_roaMWMYpglQ"},"authorGoogleplusProfileUrl": "https://plus.google.com/100517618639903741268",canRate":假,"viewerRating": "无","likeCount": 0,"publishedAt": "2015-09-27T14:56:40.258Z","updatedAt": "2015-09-27T14:56:40.258Z"}}
我在使用 API 资源管理器时得到相同的结果.
对于你的第二个例子,
https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k&fields=etag%2CeventId%2Citems%2Ckind%2CnextpageIdorCview%2Cn{YOUR_API_KEY}
给我
物品":[{"kind": "youtube#comment","etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/UBoqDwv8bg8xZpbIepzI_M5gp9o\"","id": "z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k.1409319325542384",片段":{"textDisplay": "Ahoj děkuju :) jo máš fajn videa :)","parentId": "z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k","authorDisplayName": "Gumičkování s Péťou","authorProfileImageUrl": "https://lh4.googleusercontent.com/-VJce_PtJx70/AAAAAAAAAAI/AAAAAAAAABI/dabMtsy0haY/photo.jpg?sz=50","authorChannelUrl": "http://www.youtube.com/channel/UCAyuADHtiVTpiAbt2VVQhtQ",作者频道ID":{"value": "UCAyuADHtiVTpiAbt2VVQhtQ"},"authorGoogleplusProfileUrl": "https://plus.google.com/101894467260220798842",canRate":假,"viewerRating": "无","likeCount": 0,"publishedAt": "2014-08-29T13:35:25.542Z","updatedAt": "2014-08-29T13:35:25.542Z"}}
这可能是您的请求或 API 密钥的问题.尝试制作一个新的并使用它.
I am trying to retrieve all comments to a video with all replies, however, using the Test It interface (or the Java library) I have not been able to retrieve all comments - I have following two examples, when I have failed:
Example 1
The example video and comment is https://www.youtube.com/watch?v=xCLy2DZdXhY&lc=z12ei1s5gs2mc303523qsdigcxmphhlrd04 When I retrieve the comment using
GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&id=z12ei1s5gs2mc303523qsdigcxmphhlrd04&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
I receive:
And note the "totalReplyCount": 2,
line.
However, when I try to obtain all replies using the parentId:
GET https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z12ei1s5gs2mc303523qsdigcxmphhlrd04&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
I receive an empty response:
Remarks
I have read Youtube Data API v3: commentThread call doesn't give replies for some comment threads , however, it does not provide me the answer as I do use the comments list with parentId and I am still not getting any replies.
Even if I try the not recommended way - using the part snippet,replies
, I do not get any replies:
Request:
GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&id=z12ei1s5gs2mc303523qsdigcxmphhlrd04&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
However, if I do not specify the comment thread by its ID and specify that I want all comment threads for the video:
GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&videoId=xCLy2DZdXhY&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
Then voila - The comment thread is now with those two replies:
Why do I receive the replies now and not when I either specify the replies by their parentId or when I specify the comment thread by its id?
Moreover, if I take the (weird) id of one of the replies and try to obtain the comment with this reply, I will receive empty response:
GET https://www.googleapis.com/youtube/v3/comments?part=snippet&id=z12ei1s5gs2mc303523qsdigcxmphhlrd04.1443381718685326&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
Example 2
This problem is a bit different. I have a video https://www.youtube.com/watch?v=-c76GeR2IWg with 7 comments (6 of them are top levels). When I try to obtain all top level comments related to this video I receive only 4 of them. GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&videoId=-c76GeR2IWg&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
One of the missing comments in the response is https://www.youtube.com/watch?v=-c76GeR2IWg&lc=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k . When I train to obtain comment thread with this id, I do obtain the comment thread: GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&id=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
And also, when I try to obtain the replies for this comment (there should be 1 reply) I receive an empty response:
GET https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
Remarks
For both examples, the number of comments is less than the size of the page. For this simple example, I have skipped pagination and chose examples with only a few comments, in the real application I use the pagination but I do not get more results.
I do not really understand how is the YouTube and G+ integrated together, thus this might be the issue, however, I was always accesing these videos using only youtube, not checking the users' G+ page, thus I would say that this should not be the case.
Similar questions on SO:
How can I see all the comments with the Youtube API? This is about V2 API, thus no use for me.
Youtube Data API v3: commentThread call doesn't give replies for some comment threads This question is very similar and raises similar problems, however, it is exactly the other way around - The author does not receive all replies using the commentThread replies (which is agreeing with the documentation), however, the proposed solution is "Use the comments.listcall instead and specify the commentThread's ID for the parentId." - which is exactly what does not work for me.
YouTube Data API v3 Comment Thread Discrepency The author forgot about pagination.
YouTube Data API v3 - Comment threads request doesn't return all comments Similar question, yet without any answer.
When I do the following via HTTP request:
https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z12ei1s5gs2mc303523qsdigcxmphhlrd04&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
I get the following response:
items": [
{
"kind": "youtube#comment",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/aOipn7OKd9ibVua9TWdtD2vJJgI\"",
"id": "z12ei1s5gs2mc303523qsdigcxmphhlrd04.1443381718685326",
"snippet": {
"textDisplay": "JM",
"parentId": "z12ei1s5gs2mc303523qsdigcxmphhlrd04",
"authorDisplayName": "Asia Price",
"authorProfileImageUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50",
"authorChannelUrl": "http://www.youtube.com/channel/UCtUuxM3_g2hWA7qr17d85RQ",
"authorChannelId": {
"value": "UCtUuxM3_g2hWA7qr17d85RQ"
},
"authorGoogleplusProfileUrl": "https://plus.google.com/100662746258967935686",
"canRate": false,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2015-09-27T19:21:58.685Z",
"updatedAt": "2015-09-27T19:21:58.685Z"
}
},
{
"kind": "youtube#comment",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/NtowtHGdhytzw9YY9RxUopEgoTA\"",
"id": "z12ei1s5gs2mc303523qsdigcxmphhlrd04.1443365800258222",
"snippet": {
"textDisplay": "0",
"parentId": "z12ei1s5gs2mc303523qsdigcxmphhlrd04",
"authorDisplayName": "FAY Fay",
"authorProfileImageUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50",
"authorChannelUrl": "http://www.youtube.com/channel/UC5b4dTxK4ae_roaMWMYpglQ",
"authorChannelId": {
"value": "UC5b4dTxK4ae_roaMWMYpglQ"
},
"authorGoogleplusProfileUrl": "https://plus.google.com/100517618639903741268",
"canRate": false,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2015-09-27T14:56:40.258Z",
"updatedAt": "2015-09-27T14:56:40.258Z"
}
}
I get the same results when I use the API explorer.
For your second example,
https://www.googleapis.com/youtube/v3/comments?part=snippet&parentId=z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CtokenPagination%2CvisitorId&key={YOUR_API_KEY}
gives me
"items": [
{
"kind": "youtube#comment",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/UBoqDwv8bg8xZpbIepzI_M5gp9o\"",
"id": "z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k.1409319325542384",
"snippet": {
"textDisplay": "Ahoj děkuju :) jo máš fajn videa :) ",
"parentId": "z120d11g2yyjyxcxw04cg1xbaqfnslfaamk0k",
"authorDisplayName": "Gumičkování s Péťou",
"authorProfileImageUrl": "https://lh4.googleusercontent.com/-VJce_PtJx70/AAAAAAAAAAI/AAAAAAAAABI/dabMtsy0haY/photo.jpg?sz=50",
"authorChannelUrl": "http://www.youtube.com/channel/UCAyuADHtiVTpiAbt2VVQhtQ",
"authorChannelId": {
"value": "UCAyuADHtiVTpiAbt2VVQhtQ"
},
"authorGoogleplusProfileUrl": "https://plus.google.com/101894467260220798842",
"canRate": false,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2014-08-29T13:35:25.542Z",
"updatedAt": "2014-08-29T13:35:25.542Z"
}
}
It might be an issue with your request or API key. Try making a new one and using that.
这篇关于使用 Google YouTube V3 API 未检索到回复或未检索到所有评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!