我尝试使用api过滤音乐视频。
我查看了youtube api(v3)网站,但无法找到它。
try {
// Call the search.list method to retrieve results matching the specified
// query term.
$searchResponse = $youtube->search->listSearch('id,snippet', array(
'q' => $_GET['q'],
'maxResults' => $_GET['maxResults'],
'type' => 'video',
**'videoCategoryId' => 'Music',**
));
答案 0 :(得分:3)
videoCategoryID
的{{1}}为music
。你可以在这里看到:
10
所以你的代码最终看起来像这样:
https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&id=10&key={YOUR_API_KEY}
以下是获取完整类别列表的快捷方式:
$searchResponse = $youtube->search->listSearch('id,snippet', array(
'q' => $_GET['q'],
'maxResults' => $_GET['maxResults'],
'type' => 'video',
'videoCategoryId' => '10'
));