如何使用create方法禁用sendNotificationEmails?

时间:2018-01-05 13:14:35

标签: php permissions google-drive-api email-notifications

我正在使用PHP Google Drive API V2,我想停止发送通知电子邮件,同时使用创建方法授予权限。以下是我的代码:

foreach($EMAILS as $cnt=>$email){
    $userPermission = new Google_Service_Drive_Permission(array(
    'type' => 'user',
    'role' => 'writer',            
    'emailAddress' => $email
    ));
    $request = $driveService->permissions->create(
        $fileId, $userPermission, array('fields' => 'id'));
    $batch->add($request, 'user');
    $results[] = $batch->execute();                     
} 

任何帮助?

1 个答案:

答案 0 :(得分:1)

在V2的这个文档中,我找不到权限的create方法: https://developers.google.com/resources/api-libraries/documentation/drive/v2/php/latest/class-Google_Service_Drive_Permissions_Resource.html

在V3中,它存在: https://developers.google.com/resources/api-libraries/documentation/drive/v3/php/latest/class-Google_Service_Drive_Permissions_Resource.html

对于$optParams参数,您有:

  

<强> Opt_param

     

string emailMessage 要包含在通知电子邮件中的纯文本自定义消息。

     

bool sendNotificationEmail 在与用户或群组共享时是否发送通知电子邮件。对于用户和此默认值为true   组,并且不允许其他请求。不得禁用它   所有权转移。

     

bool supportsTeamDrives 请求的应用程序是否支持Team Drives。

     

bool transferOwnership 是否将所有权转让给指定用户并将当前所有者降级为编写者。这个   需要参数作为副作用的确认。

     

bool useDomainAdminAccess 是否应将请求视为由域管理员发出;如果设置为true,那么   如果请求者是其管理员,则将被授予访问权限   该项目所属的域名。

您只需要在该参数数组中将 sendNotificationEmail 发送为false。

'sendNotificationEmails'=>false