YouTube 列表搜索过滤器

YouTube listsearch filter

简单的问题,我正在使用 google-api-php-客户端在 youtube 上搜索视频,我想将结果过滤为仅 return 视频。图书馆说你可以这样做:

By default, a search result set identifies matching video, channel, and playlist resources, but you can also configure queries to only retrieve a specific type of resource. (search.list)

但我不清楚如何。我应该如何修改查询?

$searchResponse = $youtube->search->listSearch('id,snippet', array(
      'q' => $_GET['q'],
      'maxResults' => $_GET['maxResults'],
    ));

提前致谢。

您可以将type指定为video,例如:

$searchResponse = $youtube->search->listSearch('id,snippet', array(
  'q' => $_GET['q'],
  'maxResults' => $_GET['maxResults'],
  'type' => 'video'
));

默认情况下,type 字段是 video, channel, playlist,因此默认情况下您将获得全部 3 个。