I have it
define('CLIENT_SECRET_PATH', __DIR__ . '/config_api.json');
define('ACCESS_TOKEN', '0b502651********c52b3');
I can create a table with this and get the id and URL.
$requestBody = new Google_Service_Sheets_Spreadsheet();
$response = $service->spreadsheets->create($requestBody);
print_r($response);
$new_spr_id = $response['spreadsheetId'];
But this table does not appear on the google list of sheets, because it is " protected " or something like that. I try to set permissions with this, but I get the error message: Fatal error: Call to undefined method Google_Service_Drive_Permission :: setValue ()
insertPermission($service, $new_spr_id, '**@gmail.com' , 'user', 'owner');
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;
}
I need an example of creating a new spreadsheet and setting the appropriate permissions so that I can change this spreadsheet from my account, etc.
Many thanks!
source
share