1
我有一個電子郵件地址列表,並希望通過Google雲端硬盤API授予他們對Google雲端硬盤文件夾的訪問權限。我將該電子郵件地址作爲變量傳遞給創建權限數組。但是發生錯誤說電子郵件地址無效。我用print_r()來檢查電子郵件地址,它是正確的。以下是我在PHP中使用的代碼。通過雲端硬盤API將多個用戶添加到Google雲端硬盤文件夾中
$batch = $driveService->createBatch();
// read files containing multiple email address
$myfile = fopen("emaillist.csv","r") or die("Unable to open file!");
$emailList = fread($myfile, filesize("emaillist.csv"));
fclose($myfile);
$emailListArray = explode(";", $emailList);
$index = 1;
foreach($emailListArray as $email) {
$userPermission = new Google_Service_Drive_Permission(array(
'type' => 'user',
'role' => 'reader'
'emailAddress' => $email
));
$request = $driveService->permissions->create($fileId, $userPermission, array('fields' => 'id'));
$batch->add($request, 'user'.$index);
$index++;
}
$results = $batch->execute();
任何人都可以指導我在我的代碼中出了什麼問題。謝謝!
更正:即。 'emailAddress'=>修剪($ email) – Ryan