Youtube API V3 - 如何使用频道图标字段搜索视频?

Posted

技术标签:

【中文标题】Youtube API V3 - 如何使用频道图标字段搜索视频?【英文标题】:Youtube API V3 - How to search video with channel icon field? 【发布时间】:2016-07-11 04:46:10 【问题描述】:

我想搜索视频列表并将其与频道图标一起显示在屏幕上,但我不知道如何在搜索查询中获取 channel_id 或 channel_icon 直接链接。

我在 youtube 的开发者页面 (Java) 中关注一个示例,我希望搜索结果包含 channel_id 或 channel_icon,怎么办?

search.setFields("items(id/videoId,snippet/title,snippet/thumbnails/default/url)");

[已解决] 我已经解决了我的问题,我编辑了我的字段过滤器,完整代码:

search = youtube.search().list("id,snippet");
search.setFields("items(id/videoId,snippet/title,snippet/thumbnails/default/url,snippet/channelId,snippet/channelTitle)");
// or just remove fields filter and then the response will constant all fileds for you

我得到了channelId,我可以得到频道图标,只需将url替换为我的channelId:

http://i.ytimg.com/i/[channelId]/1.jpg

【问题讨论】:

签出线程How can I get a channel ID from YouTube?。 【参考方案1】:

你是如何创建search的?

设置“sn-p”,以便 api 响应包含通道 id 和其他有用数据:

YouTube.Search.List search = youtube.search().list("id,snippet");

【讨论】:

以上是关于Youtube API V3 - 如何使用频道图标字段搜索视频?的主要内容,如果未能解决你的问题,请参考以下文章