YouTube API V3:我在哪里可以找到每个'videoCategoryId'的列表?

Har*_*ldo 17 php youtube google-api youtube-api

我正在使用Youtube API V3,但无法找到有关如何按类别过滤的文档:

这是我的代码:

$results = $youtube->search->listSearch('id,snippet', array(
    'q' =>                  $_GET['q'],
    'maxResults' =>         20,
    'type' =>               'video'
    'videoCategoryId' =>    'what-do-i-put-here?',
));
Run Code Online (Sandbox Code Playgroud)

我一直在阅读他们的文档一个小时,似乎找不到任何关于如何找出各类别ID的参考.在我的情况下,我正在寻找音乐的videoCategoryId ....

Ams*_*ser 33

使用Dinesh Gowtham Prathap的YouTube API v3视频类别ID列表,网址为https://gist.github.com/dgp/1b24bf2961521bd75d6c

1 - Film & Animation 
2 - Autos & Vehicles
10 - Music
15 - Pets & Animals
17 - Sports
18 - Short Movies
19 - Travel & Events
20 - Gaming
21 - Videoblogging
22 - People & Blogs
23 - Comedy
24 - Entertainment
25 - News & Politics
26 - Howto & Style
27 - Education
28 - Science & Technology
29 - Nonprofits & Activism
30 - Movies
31 - Anime/Animation
32 - Action/Adventure
33 - Classics
34 - Comedy
35 - Documentary
36 - Drama
37 - Family
38 - Foreign
39 - Horror
40 - Sci-Fi/Fantasy
41 - Thriller
42 - Shorts
43 - Shows
44 - Trailers
Run Code Online (Sandbox Code Playgroud)


jlm*_*ald 31

视频类别是特定于区域的 - 这就是类别列表服务需要类别ID或区域,但不需要两者的原因.这个终点:

https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode= {two-character-region}&key = {YOUR_API_KEY}

将返回给定区域的所有类别及其ID.正如Ikai Lan在评论中指出的那样,美国的音乐ID是"10",事实上,在允许这一类别的所有地区; 但可能有些地区不允许,或者某些地区根本不受支持.


小智 12

在底部:https://developers.google.com/youtube/v3/docs/videoCategories/list是'立即尝试'部分.

将"代码段"放在标记为"part"的字段中,并在标记为"regionCode"的字段中添加区域代码,例如GB或US.

这将带回您所选地区的完整类别列表.