我缺少 YouTube 数据的什么参数 API 插入方法

What paramater am I missing for YouTube Data API Insert method

我正在为这个项目使用 Google 的 Apps 脚本。我正在使用 YouTube 数据 API V3,其中 API 我正在使用 PlaylistItems class。我正在尝试将视频插入播放列表,我已经从他们提供的文档中拼凑了我能做的。

YouTube.PlaylistItems.insert({
  "part": [
    "snippet"
  ],
  "resource": {
    "snippet": {
      "playlistId": "PL5t3YGq3D2WnrLyuYL9WCgprQ2RUcwl8a",
      "position": 0,
      "resourceId": {
        "kind": "youtube#video",
        "videoId": testVidId
        // testVidId is the ID of the video I'm trying to insert
      }
    }
  }
});

当我 运行 这样做时,我得到一个错误

Exception: Invalid number of arguments provided. Expected 2-3 only

我的问题是:我缺少什么参数?

我相信你的目标如下。

  • 您想使用 Google Apps 脚本将项目插入播放列表。

修改点:

  • 当使用YouTube.PlaylistItems.insert(resource, part)时,参数为resourcepart,分别是对象和字符串数组。

当你的脚本修改后,变成如下。

修改后的脚本:

YouTube.PlaylistItems.insert(
  {
    "snippet": {
      "playlistId": "PL5t3YGq3D2WnrLyuYL9WCgprQ2RUcwl8a",
      "position": 0,
      "resourceId": {
        "kind": "youtube#video",
        "videoId": testVidId
      }
    }
  },
  ["snippet"]
);

注:

参考: