更新时间:2023-09-23 11:25:22
要喜欢" v3 中的视频,您需要将其添加到特定的播放列表 ID.(您也可以阅读此播放列表以获取您之前喜欢"的视频列表.)
To "like" a video in v3, you need to add it to a specific playlist id. (You can also read this playlist to get a list of videos that you've previously "like"d.)
正确的调用方式是 playlistItems.insert()
(即 POST 到 https://www.googleapis.com/***/v3/playlistItems
)具有以下请求正文:
The proper call to make is a playlistItems.insert()
(i.e. a POST to https://www.googleapis.com/***/v3/playlistItems
) with the following request body:
"body": {
"snippet": {
"playlistId": LIKED_LIST_ID,
"resourceId": {
"kind": "***#video",
"videoId": VIDEO_ID
}
}
}
要插入的两件事是LIKED_LIST_ID
和VIDEO_ID
.VIDEO_ID
应该是不言自明的.LIKED_LIST_ID
对应于您在发出 channels.list(part=contentDetails) 请求时返回的播放列表 ID.响应看起来像
The two things to plug in there are LIKED_LIST_ID
and VIDEO_ID
. VIDEO_ID
should hopefully be self-explanatory. LIKED_LIST_ID
corresponds to the playlist id you get back when making a channels.list(part=contentDetails) request. The response looks like
"contentDetails": {
"relatedPlaylists": {
"likes": "LL0c49w3rVoFjTkQVbyRs8Sg",
"favorites": "FL0c49w3rVoFjTkQVbyRs8Sg",
"uploads": "UU0c49w3rVoFjTkQVbyRs8Sg",
"watchHistory": "HL0c49w3rVoFjTkQVbyRs8Sg",
"watchLater": "WL0c49w3rVoFjTkQVbyRs8Sg"
}
}
您可以插入一些其他播放列表 ID,例如,将视频添加为收藏或将其添加到帐户的稍后观看列表中.该代码将与喜欢"视频的代码相同.
You can plug in some of those other playlist ids to, for instance, add a video as a favorite or add it to the watch later list for an account. The code would be identical to the code for "like"ing a video.