如何通过不使用 OAuth 的 YouTube API 知道播放列表是否私有 [英] How to know a playlist is whether private or not through YouTube API not using OAuth

查看:28
本文介绍了如何通过不使用 OAuth 的 YouTube API 知道播放列表是否私有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了播放列表状态的问题.我想要做的是获得没有 OAuth 的播放列表状态.但是,只有当我使用 playlists.list 使用 OAuth.

I'm running into a problem with status of a playlist. What I want to do is to get a playlist status without OAuth. But, it is only retrieved when I use playlists.list with OAuth.

当我使用 API_KEY 发送有关带有 playlists.list 的私人播放列表的请求时,它会响应:

When I send a request about a private playlist with playlists.list using API_KEY, it responses with:

GET https://www.googleapis.com/youtube/v3/playlists?part=id%2Csnippet%2Cstatus&id={PRIVATE_PLAYLIST_ID}&key={API_KEY}

{
 "kind": "youtube#playlistListResponse",
 "etag": "\"q5k97EMVGxODeKcDgp8gnMu79wM/zJL80hJ0IwMo5wddECFapC8I6Q4\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": [
 ]
}

这并没有为我提供任何线索,播放列表是私人的或其他状态.如果我通过 YouTube API 弄明白了,我该怎么办?

This doesn't give any clues the playlist is private or other status to me. If I figure it out through YouTube API, how should I do?

推荐答案

使用 playlistItems.list 而不是 playlist.list.

Use playlistItems.list instead of playlist.list.

它会提供一些间接信息.尽管它不能确保播放列表是完全私密的,但我认为它很有用以防万一.

It'll give kind of the indirect information. Even though it doesn't make sure a playlist is exactly private, I think it is useful just in case.

GET https://www.googleapis.com/youtube/v3/playlistItems?part=status&playlistId={PRIVATE_PLAYLIST_ID}&key={API_KEY}

{
 "error": {
  "errors": [
   {
    "domain": "youtube.playlistItem",
    "reason": "playlistItemsNotAccessible",
    "message": "The request is not properly authorized to retrieve the specified playlist.",
    "locationType": "parameter",
    "location": "playlistId"
   }
  ],
  "code": 403,
  "message": "The request is not properly authorized to retrieve the specified playlist."
 }
}

这篇关于如何通过不使用 OAuth 的 YouTube API 知道播放列表是否私有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆