从YouTube API中获取ID中的问题



我试图从Android应用中获取ID,但无法找到

https://www.googleapis.com/youtube/v3/channels?part=id&forUsername={username}&key={YOUR_API_KEY}

但是得到此响应:

    {
 "kind": "youtube#channelListResponse",
 "etag": ""sNu6csVZt536JdlmpOxN9WQSd8U/ewwRz0VbTYpp2EGbOkvZ5M_1mbo"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": []
}

我也尝试过此

https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails&mine=true&key={YOUR_API_KEY}

,但响应如下:

    {
 "error": {
  "errors": [
   {
    "domain": "youtube.parameter",
    "reason": "authorizationRequired",
    "message": "The request uses the u003ccodeu003emineu003c/codeu003e parameter but is not properly authorized.",
    "locationType": "parameter",
    "location": "mine"
   }
  ],
  "code": 401,
  "message": "The request uses the u003ccodeu003emineu003c/codeu003e parameter but is not properly authorized."
 }
}

确保执行这些呼叫时已登录OAuth,如果您要解析JSON响应以查找ID,则可以在items.id

中找到它

尝试使用channels.list try-it,我得到了正确的响应:

/**
 * API response
 */
{
  "kind": "youtube#channelListResponse",
  "etag": ""VPWTmrH7dFmi4s1RqrK4tLejnRI/X6OHzHqUUEu1okILXdfdfBbUxU"",
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 1
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": ""VPWTmrH7dFmi4s1RqrK4tLejfdf/Qw3dXynuD_IdfB1LMKjSeiDI"",
      "id": "UCTjdfopNLdfd5yXVv93Ww"
    }
  ]
}

相关内容

  • 没有找到相关文章

最新更新