如何使用 Youtube API 获取 Youtube 频道横幅? [英] How to get Youtube channel banner using Youtube API?
问题描述
我正在处理一个 PHP 项目,需要从特定用户名获取 Youtube 频道横幅(或封面照片)、头像和上传的视频.
I'm working on a PHP project that need to get Youtube channel banner (or cover photo), avatar and uploaded videos from a specific Username.
对于头像和视频,我使用:https://gdata.youtube.com/feeds/api/channels?q=用户名&alt=json&v=2
For avatar and videos, I use: https://gdata.youtube.com/feeds/api/channels?q=Username&alt=json&v=2
但是对于频道横幅,我已经在互联网上搜索过但没有运气.这里有人可以帮助我吗?非常感谢!
But for the channel banner, I have searched on the Internet but no luck. Anyone here can help me? Thank you so much!
推荐答案
您可以使用 API 的 V3 来完成.您将需要实际的频道 ID(不仅仅是用户名),然后向以下对象发出请求:
You can do it with V3 of the API. You'll need the actual channel ID (not just the username), and then do a request to:
https://www.googleapis.com/youtube/v3/channels?part=品牌设置&id={CHANNEL-ID}&key={YOUR_API_KEY}
https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id={CHANNEL-ID}&key={YOUR_API_KEY}
(请注意,您还需要来自云控制台的 API 密钥).
(Note you'll also need an API key from the cloud console).
如果您没有频道 ID,可以通过此调用从用户名中获取:
If you don't have the channel ID, you can get it from the username with this call:
https://www.googleapis.com/youtube/v3/channels?part=品牌设置&forUsername={USERNAME}&key={YOUR_API_KEY}
https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&forUsername={USERNAME}&key={YOUR_API_KEY}
这篇关于如何使用 Youtube API 获取 Youtube 频道横幅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!