YouTube API V3:我在哪里可以找到每个'videoCategoryId'的列表? [英] YouTube API V3: Where can i find a list of each 'videoCategoryId'?

查看:399
本文介绍了YouTube API V3:我在哪里可以找到每个'videoCategoryId'的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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&regionCode= {two-character-region}& key = {YOUR_API_KEY}

https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&regionCode={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'的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆