2
我得到致命錯誤:當我嘗試將文件上傳到谷歌驅動器時,找不到類「Google_Service_Drive_ParentReference」。我該如何解決它?我認爲該API錯過類 'Google_Service_Drive_ParentReference' 在Drive.php如何解決致命錯誤:找不到類'Google_Service_Drive_ParentReference'?
insertFile($service, $title, $description, $parentId, $mimeType, $filename) {
$file = new Google_Service_Drive_DriveFile();
$file->setName($title);
$file->setDescription($description);
$file->setMimeType($mimeType);
// Set the parent folder.
if ($parentId != null) {
$parent = new Google_Service_Drive_ParentReference();
$parent->setId($parentId);
$file->setParents(array($parent));
}
try {
$data = file_get_contents($filename);
$createdFile = $service->files->create($file, array(
'data' => $data,
'mimeType' => $mimeType,
));
// Uncomment the following line to print the File ID
// print 'File ID: %s' % $createdFile->getId();
return $createdFile;
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}
顯然,谷歌執行''從一個v1.1.7'重大更改v1.1.8'並刪除以前需要的類。我們不得不回到1.1.7。糟糕的Google。 –