Youtube API从Youtube用户名获取Google+ ID

时间:2015-11-17 19:28:26

标签: api youtube

我有来自youtube的YouTube用户名和频道ID。

https://www.youtube.com/user/scottmillerstyle

我需要找到与scottmillerstyle相关联的用户

有没有办法使用YouTube数据API访问设置频道的人的Google+用户名?

我一直在使用API​​资源管理器,但还没有找到解决方案。

https://developers.google.com/youtube/v3/docs/channels/list

1 个答案:

答案 0 :(得分:1)

这是可能的,但如果用户使用您开发的应用进行身份验证。

查看此回复:

 cache-control:  private, max-age=0, must-revalidate, no-transform
 content-encoding:  gzip
 content-length:  255
 content-type:  application/json; charset=UTF-8
 date:  Thu, 18 Feb 2016 19:15:40 GMT
 etag:  "DsOZ7qVJA4mxdTxZeNzis6uE6ck/Oq_w72Shc0Jbz1xT23RTCTTrK_w"
 expires:  Thu, 18 Feb 2016 19:15:40 GMT
 server:  GSE
 vary:  Origin, X-Origin
 {
   "kind": "youtube#channelListResponse",
   "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/Oq_w72Shc0Jbz1xT23RTCTTrK_w\"",
   "pageInfo": {
   "totalResults": 1,
   "resultsPerPage": 5
  },
  "items": [
   {

    "kind": "youtube#channel",
    "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/MmJKFbszvNpjgkX8YAJ4HGIfQ5E\"",
    "id": "UC_VbgAPtgDGLyRMTEBqzRaA"
   }
  ]
 }

您可以通过执行以下操作来复制此内容:

访问您提供的网址: https://developers.google.com/youtube/v3/docs/channels/list

向下滚动以试用它!并输入:

 Part:            contentOwnerDetails
 forUsername:     scottmillerstyle

点击执行。它将要求进行身份验证,然后向您显示响应。

此处Youtube记录了频道ID =(UC +用户ID)https://support.google.com/youtube/answer/3250431?hl=en

现在您知道YouTube用户ID是_VbgAPtgDGLyRMTEBqzRaA。现在我们必须弄清楚如何将YouTube用户ID转换为Google+ ID ...

我发现了这个:https://developers.google.com/+/web/api/rest/latest/people/get

这将从Google+ ID获取用户名,电子邮件,大量详细信息......但是,没有任何内容可以连接YouTube ID和Google+ ID。 Google必须认为该连接存在安全风险。让我们来看看我是如何确定的。

再次访问此链接:

https://developers.google.com/youtube/v3/docs/channels/list

向下滚动以试用它!并输入:

 part: contentDetails
 mine: true

点击执行。它会要求进行身份验证,响应将显示:

 200 OK
 - SHOW HEADERS -
 {
  "kind": "youtube#channelListResponse",
  "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/KzUqsPYNzzdoMWr6xkZBKK1GNNg\"",
  "pageInfo": {
   "totalResults": 1,
   "resultsPerPage": 1
  },
  "items": [
   {

    "kind": "youtube#channel",
    "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/IR1I4xHnZMxcbo2sT4BipUVBl-Y\"",
    "id": "UCkoYb87EdaF5XepEa5EmSgQ",
    "contentDetails": {
     "relatedPlaylists": {
      "likes": "LLkoYb87EdaF5XepEa5EmSgQ",
      "favorites": "FLkoYb87EdaF5XepEa5EmSgQ",
      "uploads": "UUkoYb87EdaF5XepEa5EmSgQ",
      "watchHistory": "HLkoYb87EdaF5XepEa5EmSgQ",
      "watchLater": "WLkoYb87EdaF5XepEa5EmSgQ"
     },
     "googlePlusUserId": "YOUR GOOGLE+ ID! FANTASTIC!"
    }
   }
  ]
 }

现在尝试相同的事情,但要获得scottmillerstyle ID:

 part: contentDetails
 forUsername: scottmillerstyle
          OR
 id:UC_VbgAPtgDGLyRMTEBqzRaA

你得到的结果没有Google+ ID

 200 OK
 - SHOW HEADERS -
 {
  "kind": "youtube#channelListResponse",
  "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/zi31_NL3JJhpDcdJWbxbZE-0Ik8\"",
  "pageInfo": {
   "totalResults": 1,
   "resultsPerPage": 1
  },
  "items": [
   {

    "kind": "youtube#channel",
    "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/8iJ_z543bWUuMxbs2hC_VTdTvZI\"",
    "id": "UC_VbgAPtgDGLyRMTEBqzRaA",
    "contentDetails": {
     "relatedPlaylists": {
      "likes": "LL_VbgAPtgDGLyRMTEBqzRaA",
      "uploads": "UU_VbgAPtgDGLyRMTEBqzRaA"
     }
    }
   }
  ]
 }