如何在Google Drive API v3中共享文件?我已经列出了文件,我想与Laravel添加共享功能?
如果您的意思是与其他用户共享文件,那么您可以执行以下操作
client = new Google_Client();
// setup the client the way you do
// ....
service = new Google_Service_Drive(client)
$role = 'writer';
$userEmail = 'user@gmail.com';
$fileId = 'The ID of the file to be shared';
$userPermission = new Google_Service_Drive_Permission(array(
'type' => 'user',
'role' => $role,
'emailAddress' => $userEmail
));
$request = $service->permissions->create(
$fileId, $userPermission, array('fields' => 'id')
);
参考:
https://developers.google.com/drive/v3/web/manage-sharing
检查我的 git 存储库以获取更多有用的示例https://github.com/sazaamout/gDrive/blob/master/gDrive.php