通过YouTube Analytics API v2创建直接HTTP请求,以查看嵌入在外部网站上的频道的视频

时间:2018-06-06 13:47:22

标签: youtube youtube-api youtube-analytics-api youtube-analytics

我是使用Google API的新手。所以,问题是我是YouTube频道的管理员(不是所有者)。我想获得嵌入在外部网站上的流量来源。所以,我创建了新项目并通过Google API Explorer形成了一个请求。这是:

https://youtubeanalytics.googleapis.com/v2/reports?dimensions=insightTrafficSourceDetail&endDate=2018-12-12&filters=insightTrafficSourceType%3D%3DEXT_URL&ids=channel%3D%3D{MY_CHANNEL}&maxResults=25&metrics=views&sort=-views&startDate=2014-05-01&key={MY_API_KEY}

结果如下:

200

- Show headers -

{
 "kind": "youtubeAnalytics#resultTable",
 "columnHeaders": [
  {
   "name": "insightTrafficSourceDetail",
   "columnType": "DIMENSION",
   "dataType": "STRING"
  },
  {
   "name": "views",
   "columnType": "METRIC",
   "dataType": "INTEGER"
  }
 ],
 "rows": [
  [
   "vk.com",
   2399
  ],
  [
   "unknown",
   872
  ],
  [
   "yandex.ru",
   23
  ]

但是当我尝试直接将请求写入浏览器地址栏时,它会说:

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "errors": [
      {
        "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
        "domain": "global",
        "reason": "unauthorized"
      }
    ],
    "status": "UNAUTHENTICATED"
  }
}

我从here

进入{API_KEY}字段

但不幸的是,结果如上所述。我究竟做错了什么?您是否可以提供逐步指导,以便为我的目标获得正确的HTTP请求,因为我找不到它?谢谢!

0 个答案:

没有答案