YouTube API v3 - 更新项目在播放列表中的位置(PlaylistItems:update)

时间:2013-04-28 16:08:26

标签: youtube-api

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

我使用的是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"
}
}

1 个答案:

答案 0 :(得分: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"
  }
 }
}

可能是配额错误:

The remote server returned an error: (403) Forbidden in Youtube api

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

执行上传时403s的一个常见原因是配额错误。以下是更多细节:

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