【发布时间】:2018-02-07 20:25:32
【问题描述】:
如何使用 YouTube IFrame API 将 YouTube 频道中的热门视频(观看次数最多)嵌入博客?
根据文档,有效的listType 参数值为playlist、search 和user_uploads。找不到列出热门视频的内容。
【问题讨论】:
标签: youtube youtube-api embed youtube-javascript-api youtube-iframe-api
如何使用 YouTube IFrame API 将 YouTube 频道中的热门视频(观看次数最多)嵌入博客?
根据文档,有效的listType 参数值为playlist、search 和user_uploads。找不到列出热门视频的内容。
【问题讨论】:
标签: youtube youtube-api embed youtube-javascript-api youtube-iframe-api
您可以使用图表参数:
chart 参数标识您要检索的图表。 可接受的值为:
- mostPopular – 返回指定 content region 和 video category 的最热门视频。
示例片段:
// Sample js code for videos.list
// See full sample for buildApiRequest() code, which is not
// specific to a particular youtube or youtube method.
buildApiRequest('GET',
'/youtube/v3/videos',
{'chart': 'mostPopular',
'regionCode': 'US',
'part': 'snippet,contentDetails,statistics',
'videoCategoryId': ''});
希望这会有所帮助。
您可以通过指定 channelId 和 order = viewcount 来执行 search->list。
order参数指定将用于在 API 响应中对资源进行排序的方法。默认值为relevance。可接受的值为:
- 日期 - 资源根据创建日期按时间倒序排列。
- rating – 资源按从高到低排序。
- 相关性 – 资源根据其与搜索查询的相关性进行排序。这是此参数的默认值。
- title - 资源按标题字母顺序排序。
- videoCount - 频道按上传视频数量的降序排列。
- viewCount – 资源按查看次数从高到低排序。对于直播,视频会在直播期间按同时观看人数排序。
【讨论】:
首先,您如何定义热门视频?例如,如果您确定热门视频是观看次数最多的视频,您可以在频道上进行搜索并按观看次数对结果进行排序。
【讨论】: