如何使用YouTube API(V3)将缩略图图像上传到YouTube频道

时间:2015-05-28 17:30:21

标签: youtube-api youtube-channels youtube-data-api

我想使用YouTube API(V3)将缩略图添加到YouTube频道。

例如:左上角的图像位于此处: https://www.youtube.com/channel/UCO7KVucOJgWRuE9P4mrv8yw

列出渠道资源: https://developers.google.com/youtube/v3/docs/channels/list

缩略图图像的路径存储在频道代码段

"snippet": {
"title": "HannahInJapana",
"description": "My name is Hannah and I am living in Osaka, Japan with my husband and daughter Ellie. Living and being a mom in a foreign country comes with both challenges and excitement. I hope to both share my experiences with you and meet people who are making their way in foreign countries with young children.",
"publishedAt": "2011-03-25T09:58:45.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-DqmCXHftE-I/AAAAAAAAAAI/AAAAAAAAAAA/3k1uCwnmlu4/s88-c-k-no/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-DqmCXHftE-I/AAAAAAAAAAI/AAAAAAAAAAA/3k1uCwnmlu4/s240-c-k-no/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-DqmCXHftE-I/AAAAAAAAAAI/AAAAAAAAAAA/3k1uCwnmlu4/s240-c-k-no/photo.jpg"
}
},

首先,我需要能够通过YouTube API上传我的缩略图,然后检索我以后可以设置的图片的网址。

例如:

    channel.Snippet.Thumbnails.Default.Url = "https://yt3.ggpht.com/-DqmCXHftE-I/AAAAAAAAAAI/AAAAAAAAAAA/3k1uCwnmlu4/s240-c-k-no/photo.jpg";
    channel.Snippet.Thumbnails.Default.Height = 120;
    channel.Snippet.Thumbnails.Default.Width = 800;

我的问题是YouTube API文档中没有任何地方说明如何上传频道缩略图......

下面的文档说明了如何上传视频资源的缩略图,但没有提及频道 https://developers.google.com/youtube/v3/docs/thumbnails

如何使用YouTube API(V3)上传频道缩略图?

通道缩略图图片似乎与Google+帐户相关联。

我应该更新Google+个人资料图片吗?

Google+ API似乎不支持更新个人资料图片

1 个答案:

答案 0 :(得分:1)

<强>校正:

youtube频道中的channel-header-profile-image,例如

enter image description here

https://www.youtube.com/user/achanoi中的

与图像相同

在相应的Google Plus个人资料https://plus.google.com/106231037176903967640/videos中找到。

根据https://stackoverflow.com/a/20501327/3303824设置缩略图似乎并不简单 和https://developers.google.com/+/domains/profiles

然而,从Google Developer Directory API Update User Photo Image,PUT请求:

PUT https://www.googleapis.com/admin/directory/v1/users/userKey/photos/thumbnail

使用:

{
    "kind": "admin#directory#user#photo",
    "id": string,
    "etag": etag,
    "primaryEmail": string,
    "mimeType": string,
    "height": integer,
    "width": integer,
    "photoData": bytes
}

就够了。

<强>当时:

YouTube API V3规范中,频道对象具有:

{
 "kind": "youtube#channel",
 "etag": etag,
 "id": string,
 "image": {
  "bannerImageUrl": string,
  "bannerMobileImageUrl": string,
  "watchIconImageUrl": string,
  "trackingImageUrl": string,
  "bannerTabletLowImageUrl": string,
  "bannerTabletImageUrl": string,
  "bannerTabletHdImageUrl": string,
  "bannerTabletExtraHdImageUrl": string,
  "bannerMobileLowImageUrl": string,
  "bannerMobileMediumHdImageUrl": string,
  "bannerMobileHdImageUrl": string,
  "bannerMobileExtraHdImageUrl": string,
  "bannerTvImageUrl": string,
  "bannerTvLowImageUrl": string,
  "bannerTvMediumImageUrl": string,
  "bannerTvHighImageUrl": string,
  "bannerExternalUrl": string
 }
}

集:

brandingSettings.image.bannerExternalUrl