I believe your goal and situation as follows.
- You want to create new shortcut using googleapis for php.
- You have already been able to use Drive API.
In this case, I would like to propose to use setShortcutDetails()
in your script. When your script is modified, it becomes as follows.
Modified script:
$file = new \Google_Service_Drive_DriveFile();
$file->setName('Shortcut Name');
$file->setParents([$parent_id]);
$file->setMimeType('application/vnd.google-apps.shortcut');
$shortcutDetails = new \Google_Service_Drive_DriveFileShortcutDetails();
$shortcutDetails->setTargetId($file_id);
$file->setShortcutDetails($shortcutDetails);
$createdFile = $service->files->create($file);
- Please set
$parent_id
and$file_id
.
References:
CLICK HERE to find out more related problems solutions.