Youtube Data API v3: like comment of another user

匆匆过客 提交于 2019-12-04 01:57:27

问题


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:


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.



来源:https://stackoverflow.com/questions/37135693/youtube-data-api-v3-like-comment-of-another-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!