Youtube Data API v3:commentThread 调用不回复某些评论线程 [英] Youtube Data API v3: commentThread call doesn't give replies for some comment threads

查看:30
本文介绍了Youtube Data API v3:commentThread 调用不回复某些评论线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调用 commentThread API 时遇到问题.这是一个具体案例:评论 id:z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k

)

正如你所注意到的;有 39 条回复(评论)不正确.即使我们有回复;没有回复部分.我错过了什么吗?

两个问题:为什么回复数量不匹配?为什么那个commentThread有39条回复也没有回复?

注意:作为 part,我使用的是片段,回复".我没有收到任何 API 错误(例如节流或违反限制)

解决方案

来自 commentThreads 文档:

<块引用>

commentThread 资源不一定包含对一个评论,如果你想,你需要使用 comments.list 方法检索特定评论的所有回复.

改用 comments.list 调用并指定 commentThread 的 ID对于 parentId.

当我进行以下调用时:

https://www.googleapis.com/youtube/v3/comments?part=snippet,id&parentId=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&key=[API_KEY_HERE]&order=time&maxResults=50

我收到了对您提到的评论线程的所有 (44) 条回复.

解决您的问题:

<块引用>

为什么回复数量不匹配?

如果我不得不猜测,我会说这可能是由于 API 如何区分评论和评论线程(它考虑对线程中其他回复的回复,而不是它们与视频本身相关联).由于文档说 commentThread 资源可能不包含对评论的所有回复,我认为这仍然按预期工作.无论如何,在未来,报告的回复数量通常会更好,因为 API 更有可能遗漏某些结果而不是报告额外的结果.另外,请记住,如果您想要某个评论线程的所有回复,则应该使用 comments.list.

<块引用>

为什么那个 commentThread 有 39 条回复却没有回复?

老实说,我不确定这是 YouTube 的东西还是 G+ 的东西.当我查看其他一些有回复的评论线程时,当指定了视频 ID 时,我能够通过 API 调用看到它们.但是,正如 Daniel 所提到的,您实际上无法看到您在视频本身上指定的线程的回复(但您可以在转到该用户的 G+ 页面时看到它们).用户可能对他们的 G+ 设置做了一些关于他们共享帖子的评论的操作,这就是为什么他们没有出现在视频本身中,因此没有出现在 commentThreads 列表请求中.除非您与熟悉 G+/YouTube 集成的人交谈,否则很难说.

I have a problem with commentThread API call. Here is one specific case: comment id: z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k

https://www.googleapis.com/youtube/v3/commentThreads?id=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&part=snippet%2C+replies&key={YOUR_DEVELOPER_KEY}&alt=json&order=time

There are 44 replies for now.

But if you use video_id (not comment id like we did above. Link: https://www.googleapis.com/youtube/v3/commentThreads?videoId=Ui-ulCWmpOU&maxResults=100&pageToken=ChYQp7fipbfsxgIYkNGqiobjxQIgACgDEhQIABCQ0aqKhuPFAhiMqqKive-5AhgCIKwC&part=snippet%2C+replies&key={YOUR_DEVELOPER_KEY}&alt=json&order=time) and come across the comment (you may have to use pageToken to iterate over pages) you will see this:

(Screenshot: https://www.dropbox.com/s/d4bf9tk51eaw7dr/Screenshot%202015-07-21%2021.08.31.png?dl=0)

As you noticed; there is 39 replies (comments) which is not true. And even if we have replies; there is no replies section. Am I missing something?

Two questions: Why number of replies don't match? Why that commentThread doesn't have replies even it has 39 replies?

Notes: As part I am using 'snippet, replies'. I don't get any API error (like throttle or limit violation)

解决方案

From the commentThreads documentation:

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.

Use the comments.list call instead and specify the commentThread's ID for the parentId.

When I do the following call:

https://www.googleapis.com/youtube/v3/comments?part=snippet,id&parentId=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&key=[API_KEY_HERE]&order=time&maxResults=50

I get all (44) of the responses to the comment thread you mentioned.

To address your questions:

Why number of replies don't match?

If I had to guess, I'd say it might be due to how the API differentiates between comments and comment threads (where it considers replies to other replies in a thread as opposed to them being associated with the video itself). Since the documentation says that the commentThread resource might not contain all replies to a comment, I think this is still working as intended. At any rate, in the future it's generally better to just go with the higher number of replies reported, since it's more likely that the API is missing some results than reporting extra results. Also, remember that you should be using comments.list if you want all of the replies to a certain comment thread.

Why that commentThread doesn't have replies even it has 39 replies?

To be honest, I'm not sure if it's a YouTube thing or a G+ thing. When I looked at some of the other comment threads that had replies, I was able to see them via the API call when video ID is specified. However, as Daniel mentioned, you can't actually see the replies for the thread you specified on the video itself (but you can see them when you go to that user's G+ page). It's possible that user did something to their G+ settings regarding comments on their shared posts, which is why they aren't showing up on the video itself and thus not showing up in the commentThreads list request. It's hard to say unless you talked to someone who's familiar with G+/YouTube integration.

这篇关于Youtube Data API v3:commentThread 调用不回复某些评论线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆