Youtube Data API v3: like comment of another user

2019-02-20 10:28发布

I want to use the Youtube Data API to like comments. When I try to like a comment from myself it works without any problem, but when I try to like a comment from someone else I get an error.

"reason": "invalidCommentMetadata",
"message": "The request metadata is invalid.",

I am using the Google API PHP Client.

This is the code that I use to update the like:

$videoComments = $youtube->comments->listComments('snippet', array(
     'id' => $comment->id
));

$videoComments[0]->snippet->viewerRating = 'like';

$videoCommentUpdateResponse = $youtube->comments->update('snippet', $videoComments[0]);

I believe this is the way to do this, because when I look at the docs the only thing that I can find that affects the like is the `viewerRating.

https://developers.google.com/youtube/v3/docs/comments#properties

snippet.viewerRating string The rating the viewer has given to this comment. Note that this property does not currently identify dislike ratings, though this behavior is subject to change. In the meantime, the property value is like if the viewer has rated the comment positively.

The value is none in all other cases, including the user having given the comment a negative rating or not having rated the comment.

Valid values for this property are: - like - none

I don't know if I do something wrong, or if this is even possible. I hope someone can help me out here.

1条回答
▲ chillily
2楼-- · 2019-02-20 11:06

I think it's safe to conclude this feature does not exist for the following reasons,

The otherwise thorough API documentation makes no mention of this feature. I highly doubt youtube/google would forget to document a feature. This question has been asked several times before on SO; all of which have no accepted answer (1, 2, 3). With the oldest question being 10 months old, it's very unlikely no one would have found this feature if it did exist. Youtube is a common target of voter-bots and hence it would make sense to not offer an API entry-point as a first line of defense. The official Youtube (android) app offers no comment-upvote option but only flag and reply options. If a comment-upvote feature would exist, you'd think Youtube would show it off in their own app.

查看更多
登录 后发表回答