Skip to content

Instantly share code, notes, and snippets.

@amilabandara
Created November 2, 2015 04:09
Show Gist options
  • Save amilabandara/f0a32265135d65e3cb61 to your computer and use it in GitHub Desktop.
Save amilabandara/f0a32265135d65e3cb61 to your computer and use it in GitHub Desktop.
<?php
//add this function to your page
//after creation of file run the function in order to change the permission
function insertPermission($service, $fileId, $value, $type, $role) {
$newPermission = new Google_Service_Drive_Permission();
$newPermission->setValue($value);
$newPermission->setType($type);
$newPermission->setRole($role);
try {
return $service->permissions->insert($fileId, $newPermission);
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
return NULL;
}
$permission_data = insertPermission($service, $fileId, 'your email address', 'anyone', 'reader');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment