1
Google 드라이브 PHP API를 사용하여 스프레드 시트를 만들어야합니다. 어떻게해야합니까?PHP google 드라이브 api 스프레드 시트 만들기
/**
* Insert new file.
*
* @param apiDriveService $service Drive API service instance.
* @param string $title Title of the file to insert, including the extension.
* @param string $description Description of the file to insert.
* @param string $parentId Parent folder's ID.
* @param string $mimeType MIME type of the file to insert.
* @param string $filename Filename of the file to insert.
* @return DriveFile The file that was inserted. NULL is returned if an API error occurred.
*/
function insertFile($service, $title, $description, $parentId, $mimeType, $data) {
$file = new DriveFile();
$file->setTitle($title);
$file->setDescription($description);
$file->setMimeType($mimeType);
// Set the parent folder.
if ($parentId != null) {
$parentsCollectionData = new DriveFileParentsCollection();
$parentsCollectionData->setId($parentId);
$file->setParentsCollection(array($parentsCollectionData));
}
try {
$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => $mimeType,
));
// Uncomment the following line to print the File ID
// print 'File ID: %s' % $createdFile->getId();
print_r($createdFile);
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}
if(isset($_POST['insertFile'])){
$service = new apiDriveService($client);
insertFile($service,'Google Maps Mrakers.txt','ADD Google Map Mrakers To File',NULL,'text/plain',$_POST['data']);
exit;
}
새 라이브러리를 사용하여 스프레드 시트를 만드는 방법은 무엇입니까? –
파일의 'mimeType'을 'application/vnd.google-apps.spreadsheet'로 설정하면 사용자의 Google 드라이브에 빈 스프레드 시트가 생성됩니다. – Alain
Thx @Alain 귀하의 모든 노력에 대한 답변이 정확합니다. 어떻게 빈 스프레드 시트에 내용을 넣을 수 있습니까? –