如何使用PHP从Google Team Drive获取所有照片?

时间:2018-12-13 08:14:28

标签: php google-api-php-client

是否可以使用PHP从Google Team Drive获取所有照片?

<?php 
require_once '/vendor/autoload.php';

$client = new Google_Client();
$client->setApplicationName('Google Drive API PHP Quickstart');
$client->setScopes(Google_Service_Drive::DRIVE);
$client->setAuthConfig(__DIR__ . '/themejson.json');
//$client->setAccessType('offline');
$service = new Google_Service_Drive($client);

$folderId = 'xxxxxxxxxxxxx';
// Print the names and IDs for up to 10 files.
$optParams = array(
  "q" => "'$folderId' in parents",
  'pageSize' => 20,
  'corpora' => "user,allTeamDrives",
  'includeTeamDriveItems' => true,
  'supportsTeamDrives' => true
);
$results = $service->files->listFiles($optParams);

if (count($results->getFiles()) == 0) {
    print "No files found.\n";
} else {
    print "Files:\n";
    foreach ($results->getFiles() as $file) {
        printf("%s (%s)\n", $file->getName(), $file->getId());
    }
}
?>
我用上面的代码尝试过,但是不能正常工作。当我使用上面的代码

时,什么也没有返回

0 个答案:

没有答案