我使用谷歌API客户端库。
我不明白如何根据文件名或文件夹ID喜欢拿文件列表: -
驱动器的文件夹结构
Main =>
- Demo 1
- img.png
- img2.png
- Demo 2
- img_Demo 2.png
- img2_Demo 2.png
- Demo 3
- img_Demo 3.png
- img2_Demo 3.png
现在,我得到的主要文件夹列表和ID使用下面的代码
<?php
// include your composer dependencies
require_once 'vendor/autoload.php';
#https://developers.google.com/api-client-library/php/auth/web-app
$client = new Google_Client();
$client->setAuthConfig('client_secret.json');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
$client->setAccessToken('AccessToken');
$drive = new Google_Service_Drive($client);
$files_list = $drive->files->listFiles(array())->getFiles($optParams);
echo "<pre>";
print_r($files_list);
exit;
?>
我得到这样的输出:
Array
(
[0] => Google_Service_Drive_DriveFile Object
(
[id] => 1LKMiCuI3OlUYrFlQnl
[imageMediaMetadataType:protected] => Google_Service_Drive_DriveFileImageMediaMetadata
[imageMediaMetadataDataType:protected] =>
[isAppAuthorized] =>
[kind] => drive#file
[lastModifyingUserType:protected] => Google_Service_Drive_User
[mimeType] => application/vnd.google-apps.folder
[name] => main
)
)
拥有的File.List Q参数,这将让你qazxsw POI文件。下面将返回有1234567父ID的所有文件是要查找的目录文件ID。
search
您可以发送第q PARAM为您optParams的一部分
'1234567' in parents