0

如何更新项目在播放列表中的位置?

我使用了 API Explorer: https ://developers.google.com/youtube/v3/docs/playlistItems/update#try-it

部分:片段

请求正文:

{
  "id": "12345",
  "snippet": 
  {
    "playlistId": "my_playlist_id",
    "resourceId": 
    {
      "kind": "youtube#video",
      "videoId": "my_video_id"
    },
    "position": 3
  }
}

回复:

403 Forbidden

Cache-Control:  private, max-age=0
Content-Encoding:  gzip
Content-Length:  125
Content-Type:  application/json; charset=UTF-8
Date:  Sun, 28 Apr 2013 14:23:37 GMT
Expires:  Sun, 28 Apr 2013 14:23:37 GMT
Server:  GSE

{
"error": {
"errors": [
{
"domain": "youtube.common",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
4

1 回答 1

0

我试过了,我认为 API 调用工作正常:

Request

PUT https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails%2Cstatus&fields=id%2Csnippet&key={YOUR_API_KEY}

Content-Type:  application/json
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "id": "PLSvpjjbPJQDXYjfamKNrJHvyvkBfr7n1QwkVWH-4kWwk",
 "snippet": {
  "playlistId": "PLF-2B3_5y4x_yqhdqjdrXuse2AcK7i3XE",
  "resourceId": {
   "kind": "youtube#video",
   "videoId": "MP1gvGcXcLk"
  },
  "position": 1
 }
}

Response

200 OK

- Show headers -

{
 "id": "PLSvpjjbPJQDXYjfamKNrJHvyvkBfr7n1QwkVWH-4kWwk",
 "snippet": {
  "publishedAt": "2013-03-01T16:33:20.000Z",
  "channelId": "UC4_r417bYTsCoaVGgH1yYTg",
  "title": "Amazing Google Glasses Demonstration at Google I/O 2012",
  "thumbnails": {
   "default": {
    "url": "https://i.ytimg.com/vi/MP1gvGcXcLk/default.jpg"
   },
   "medium": {
    "url": "https://i.ytimg.com/vi/MP1gvGcXcLk/mqdefault.jpg"
   },
   "high": {
    "url": "https://i.ytimg.com/vi/MP1gvGcXcLk/hqdefault.jpg"
   }
  },
  "channelTitle": "Matias Molinas",
  "playlistId": "PLF-2B3_5y4x_yqhdqjdrXuse2AcK7i3XE",
  "position": 1,
  "resourceId": {
   "kind": "youtube#video",
   "videoId": "MP1gvGcXcLk"
  }
 }
}

也许这是一个配额错误:

远程服务器返回错误:(403) Forbidden in Youtube api

HTTP 403 响应可能与许多不同的错误相关联,查看实际响应 HTTP 正文(或在 exception.Response 属性中报告的序列化版本)是确定确切原因的唯一方法。

但是,执行上传时出现 403 的一个非常常见的原因是配额错误。以下是更多详细信息:

http://apiblog.youtube.com/2010/02/best-practices-for-avoiding-quota.html

于 2013-04-30T13:26:28.860 回答