1

我在使用 Google API 方面很陌生。所以,问题是我是 YouTube 频道的管理员(不是所有者)。我想获得嵌入在外部网站上的流量资源。因此,我创建了新项目并通过 Google APIs 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"
  }
}

我从这里推入 {API_KEY} 字段

但是,不幸的是,结果如上所示。我究竟做错了什么?您能否提供分步说明以获取正确的 HTTP 请求以实现我的目标,因为我找不到它?谢谢!

4

0 回答 0