我正在开发一个PHP项目,需要从特定的用户名获取Youtube频道横幅(或封面照片),头像和上传的视频.
对于头像和视频,我用: https://gdata.youtube.com/feeds/api/channels?q=Username&alt=json&v=2
但对于频道横幅,我在互联网上搜索但没有运气.这里有人可以帮帮我吗?非常感谢!
使用YouTube API v3查询频道的品牌设置时,为什么他们会按渠道ID返回查询,但不会按用户名查询?API不会按用户名返回频道列表查询的品牌设置.
如果您按频道ID(例如id=UC8-Th83bH_thdKZDJCrn88g)查询频道的品牌设置,则会返回一组完整的品牌设置:
Google API Explorer:https://developers.google.com/youtube/v3/docs/channels/list
请求
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UC8-Th83bH_thdKZDJCrn88g&key={YOUR_API_KEY}
Run Code Online (Sandbox Code Playgroud)
响应
{
// ... snip ...
"items": [
{
"kind": "youtube#channel",
"etag": "\"...\"",
"id": "UC8-Th83bH_thdKZDJCrn88g",
"brandingSettings": {
"channel": {
"title": "The Tonight Show Starring Jimmy Fallon",
"description": "Watch The Tonight Show Starring Jimmy Fallon Weeknights 11:35/10:35c\n\nThe Tonight Show Starring Jimmy Fallon features hilarious highlights from the show including: comedy sketches, music parodies, celebrity interviews, ridiculous games, and, of course, Jimmy's Thank You Notes and hashtags! …Run Code Online (Sandbox Code Playgroud)