问题描述
我使用的是 Youtube API V3,但找不到有关如何按类别过滤的文档:
I'm using the Youtube API V3 but can't find documentation for how to filter by category:
这是我的代码:
$results = $youtube->search->listSearch('id,snippet', array(
'q' => $_GET['q'],
'maxResults' => 20,
'type' => 'video'
'videoCategoryId' => 'what-do-i-put-here?',
));
我已经浏览了他们的文档一个小时,但似乎找不到任何关于我如何找出各种类别的 ID 的参考.就我而言,我正在寻找音乐的 videoCategoryId....
I've been going through their documentation for an hour and can't seem to find any reference to how I find out what the various category's ids are. In my case I'm looking for the videoCategoryId for music....
推荐答案
视频类别是特定于区域的——这就是类别列表服务需要类别 ID 或区域,但不能同时需要两者的原因.此端点:
Video categories are region specific -- that's why the category list service requires either a category ID or a region, but not both. This endpoint:
https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode={two-character-region}&key={YOUR_API_KEY}
https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode={two-character-region}&key={YOUR_API_KEY}
将返回给定区域的所有类别及其 ID.因此,正如 Ikai Lan 在评论中指出的那样,音乐的 ID 在美国是10",事实上,在所有允许此类别的地区;但可能有些地区不允许,或者有些地区根本不支持.
will return all categories, along with their ids, for a given region. So as Ikai Lan pointed out in the comments, the ID for music is '10' in the US and, in fact, in all regions where this category is allowed; but there may be some regions where it isn't allowed, or some regions that aren't supported at all.
这篇关于YouTube API V3:在哪里可以找到每个“videoCategoryId"的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)