我在哪里使用 Google API 客户端库指定 "fields" 参数 - PHP(测试版)

Where do i specify the "fields" parameter using the Google API Client Library - PHP (Beta)

我正在使用 Google API 客户端库 - PHP(测试版)用于 YouTube 数据 api v3 我正在根据文档进行播放列表列表操作: https://developers.google.com/youtube/v3/docs/playlistItems/list 但是我找不到使用 API 客户端库提供字段参数的方法。

有谁知道我会去做吗?

谢谢

fields 是标准查询参数 (as defined here)。

Youtube应该支持API,你可以在$params数组参数中传递它,与$maxResults等一起传递。请参考你提供给的示例看看 $params.

在哪里

$queryParams

中定义
...

// Define service object for making API requests.
$service = new Google_Service_YouTube($client);


$queryParams = [
  'maxResults' => 3,
  'type' => 'video',
  'q' => 'car',
  'fields' => 'items(snippet(title))'
];

$response = $service->search->listSearch('snippet', $queryParams);
...