我正在创建一个新文档并将其分享给所有人,但除非我手动返回文档并再次共享,否则任何人都无法编辑该文档。我正在使用这个库:https://github.com/google/google-api-php-client。请注意,当我查看驱动器上的文档时,它会将其分享给任何人,并且他们可以编辑,但事实并非如此:
private function make_file($service, $name, $content, $parent_id) {
$parent = new Google_Service_Drive_ParentReference();
$parent->setId($parent_id);
$permission = new Google_Service_Drive_Permission();
$permission->setType('anyone');
$permission->setRole('writer');
$permission->setWithLink(true);
$permission->setValue(null);
$file = new Google_Service_Drive_DriveFile();
$file->setTitle($name);
$file->setParents(array($parent));
$new_file = $service->files->insert(
$file,
array(
'data' => $content,
'mimeType' => 'text/html',
'uploadType' => 'media',
'convert' => true
)
);
$service->permissions->insert($new_file->getId(), $permission);
return $new_file;
}