开发者

YouTube API PHP - Like or Dislike video after authentication

开发者 https://www.devze.com 2023-02-07 11:33 出处:网络
I\'m using PHP and Zend to pull in my videos from YouTube.I\'m authenticated with AuthSub and can post comments successfully.

I'm using PHP and Zend to pull in my videos from YouTube. I'm authenticated with AuthSub and can post comments successfully.

I now wish to click on 'like' or 'dislike'. The PHP API guide only has the old star rating detailed: http://code开发者_运维技巧.google.com/apis/youtube/2.0/developers_guide_php.html#Adding_a_Rating

But how can I do the same thing for the new rating system?


I know the question is quite old, but hopefully my answer will be useful for anyone finding this post via Google.

The like/dislike element is documented at http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_yt:rating

and the protocol examples are at http://code.google.com/apis/youtube/2.0/developers_guide_protocol_ratings.html

The documentation says that in order to dislike/like a video, you can send an authenticated POST request to the video's ratings URL and set the value to "like"/"dislike".

As an alternative to setting like/dislike in your request (i.e. when using a library that requires numeric input) you could also rely on the fact that a 1 rating in the older numeric rating system corresponds to a "dislike" and a 5 rating corresponds to a "like".

Hope I could help.


Also for future reference, here's how the same sort of operation can be done using version 3 of the YouTube Data API: YouTube API v3: Liking a video in Python

0

精彩评论

暂无评论...
验证码 换一张
取 消