【发布时间】:2018-05-08 19:23:59
【问题描述】:
我正在使用以下代码连接 G-API 并向其发出请求:
require_once '/google-api/vendor/autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=/mySecretFile.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope("https://www.googleapis.com/auth/drive");
$service = new Google_Service_Drive($client);
$files = $service->files->listFiles()->getFiles();
foreach($files as $file){
print_r($file);
}
我尝试了这段代码几次,所有的结果都只有一个文件,我相信它不是我的,因为它不存在于我的驱动器中,所以发生了什么?这是我得到的唯一文件的图像。
【问题讨论】:
-
如果您的文件存在于 Gdrive 中,请尝试使用 Try it now list。然后你可以参考这个github post on how to Lists or searches files。查找列表或搜索文件作为关键字在代码中搜索。
标签: php google-api google-drive-api google-api-php-client service-accounts