setAuthConfig($serviceAccountKeyFile); $client->addScope(Google_Service_Drive::DRIVE); // Google Drive 서비스 초기화 $service = new Google_Service_Drive($client); // 특정 폴더 확인 함수 function getFolderId($service, $folderName, $parentFolderId = null) { $query = "name='$folderName' and mimeType='application/vnd.google-apps.folder' and trashed=false"; if ($parentFolderId) { $query .= " and '$parentFolderId' in parents"; } $response = $service->files->listFiles([ 'q' => $query, 'spaces' => 'drive', 'fields' => 'files(id, name)' ]); return count($response->files) > 0 ? $response->files[0]->id : null; } ?>