4
votes

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:

39 replies but no replies section

(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)

2

2 Answers

2
votes

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.

1
votes

While I wasn't able to answer your questions definitely, I was able to find some useful info that may give you some clarity and direction.

With regard to the specific case outlined in your question: the user "authorDisplayName": "Tammy L." commented on the video "videoId": "Ui-ulCWmpOU" on 11/16/2013, and received replies between 11/16/2013 and 11/18/2013. According to Tammy L.'s record on Google+, there are 44 replies to her initial comment from this date:

enter image description here

Although, according to the record on YouTube, it appears that there are 42 replies to her comment, which doesn't match either value returned from your API calls. Even more bizarre, Google won't display the comments when I click on "View all 42 replies":

enter image description here

It seems that the commentId call provides the correct number of replies made to Tammy L.'s initial comment, which is consistent with the number of replies shown on her Google+ account. Perhaps the issues with the videoId call (including the fact that this call doesn't provide replies) are attributable to the changes Google implemented around the time that Tammy L. made her initial comment (November 2013), although I'm not totally sure.