我使用的是PHP和Google Drive API,需要获取返回对象中所有文件的fileId。
这是我的代码:
$result = array();
$files = array();
$pageToken = NULL;
try {
$parameters = array();
$parameters['pageToken'] = $pageToken;
$parameters['q'] = "trashed=false and title contains '".$folderName."'";
$files = $this->service->files->listFiles($parameters);
$result = array_merge($result, $files->getItems());
$pageToken = $files->getNextPageToken();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
$pageToken = NULL;
}
print_r($result);
如何获取$ result变量中所有文件的fileId?
答案 0 :(得分:0)
只是做:
foreach($files->items as $item)
{
echo $item['id'];
}