【问题标题】:contentDetails don't exist in some responses of Activities with YouTube Data API v3使用 YouTube 数据 API v3 的活动的某些响应中不存在 contentDetails
【发布时间】:2017-02-21 11:47:15
【问题描述】:

我在使用 YouTube API 时遇到问题。 我要求如下:

http://www.googleapis.com/youtube/v3/activities?part=contentDetails&channelId={CHANNEL_ID}&key={YOUR_API_KEY}

然后我收到了回复:

{
 "kind": "youtube#activityListResponse",
 ....
 "items": [
  {
   "kind": "youtube#activity",
   "etag": etag1,
   "id": id1,
  },
  ....

虽然我指定了 contentDetails ,但它没有属性。它存在于下一个活动中。

  ....
  {
   "kind": "youtube#activity",
   "etag": etag2,
   "id": id2,
   "contentDetails":{
    "upload":{
     "videoID": videoed
    }
   }
  },
  ....

contentDetails是否存在取决于什么?事实上,第一个活动是“公告”,而第二个活动是“上传”。有这个顾虑吗?

【问题讨论】:

  • 给我看说明 contentDetails 包含“comment”、“likes”的文档。我想你指的是"Youtube Metrics"

标签: api youtube-api youtube-data-api


【解决方案1】:

这是contentDetails 的预期响应——它只返回videoId。你可以看到Activities resource

"contentDetails": {
    "upload": {
      "videoId": string
    }

您甚至可以在Google API Explorer Activities.list 中尝试此操作,请务必在“使用字段编辑器”中勾选“全部”。

如果您想要更详细的回复,请使用snippet

 "snippet": {
    "publishedAt": datetime,
    "channelId": string,
    "title": string,
    "description": string,
    "thumbnails": {
      (key): {
        "url": string,
        "width": unsigned integer,
        "height": unsigned integer
      }
    },
    "channelTitle": string,
    "type": string,
    "groupId": string
  }

【讨论】:

  • “contentDetails”包含“like”、“favorite”、“comment”、“subscription”、“playlistItem”、“recommendation”、“bulletin”和“social”,而不仅仅是“upload”。
猜你喜欢
  • 2014-03-06
  • 2013-08-10
  • 2015-02-08
  • 2015-12-07
  • 2014-10-31
  • 2014-09-22
  • 1970-01-01
  • 2016-06-08
  • 1970-01-01
相关资源
最近更新 更多