How to get a user's Google+ ID from a YouTube channel ID

試著忘記壹切 提交于 2019-12-06 06:02:36
Michael Waltman

googlePlusUserId is now deprecated from

https://developers.google.com/youtube/v3/docs/channels#properties

contentDetails.googlePlusUserId no longer exists as part of the contentDetails part.

Based on this excerpt from their change-log

June 13, 2016

This update contains the following changes:

  • The channel resource's contentDetails.googlePlusUserId property has been deprecated. Previously, the property was only present if the channel was associated with a Google+ profile. Following the deprecation, the property will no longer be included in any channel resources.
  • The comment resource's snippet.authorGoogleplusProfileUrl property has been deprecated. Previously, the property was only present if the channel was associated with a Google+ profile. Following the deprecation, the property will no longer be included in any comment resources.

Since neither of these properties will be returned following the deprecation, both properties have been removed from the corresponding resource documentation.

You can get user Google+ ID through a YouTube API(v3) request, e.g.:

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

Will return:

{
   "kind": "youtube#channelListResponse",
   "etag": "fooHash",
   "pageInfo": {
      "totalResults": 1,
      "resultsPerPage": 1
   },
   "items": [{
         "kind": "youtube#channel",
         "etag": "fooHash",
         "id": "fooHash",
         "contentDetails": {
            "relatedPlaylists": {
               "likes": "fooHash",
               "favorites": "fooHash",
               "uploads": "fooHash"
             },
          }
          "googlePlusUserId": "{ID}"
   }]
}

Probably people can not get Google+ ID from YouTube API(v3). But even the channel owner did not create google plus account, you can know it in advance on the channel HTML document by using XHR or curl.

  1. visit channel page.

    https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ

  2. Catch Javascript object from Developer tool on browser at the page.

    ytInitialData.metadata.channelMetadataRenderer.ownerUrls

    [ "http://www.youtube.com/user/googlechrome",
    "https://plus.google.com/100585555255542998765" ]

  3. Second one is always google plus address and the number is Google+ ID. You can get more info from ytInitialData at the channel page if necessary.

One example. https://www.youtube.com/channel/UCiQPrVjbUlZBWY0fVtvpoKg

About that channel id(UCiQPrVjbUlZBWY0fVtvpoKg) You can not get Google+ ID from YouTube API(v3), but you can get Google+ ID at the channel directly when you can access html document or read it. Even if the channel owner did not create google plus account, the Youtube already made Google+ ID together.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!