0

上传文件并立即执行权限->更新:

public function  sharingFile() {
    $fileId = $this->file['id'];
    $permissionId = $this->file['userPermission']['id'];
    try {
        $permission = $this->service->permissions->get($fileId, $permissionId);
        $permission->setRole('writer');
        $permission->setType('default');
        print_r($permission);
        return $this->service->permissions->update($fileId, $permissionId, $permission);
    } catch (Exception $e) {
        return "Error: " . $e;
    }
    return NULL;
}

并得到一个错误:

Error: exception 'Google_ServiceException' with message 'Error calling PUT
https://www.googleapis.com/drive/v2/files/0B6xE_F1PfpXTbF9IdHgxbEJueEk/permissions/me:
(400) Bad Request' in Z:\home\site.com\www\google-api-php-client\src\io\Google_REST.php:66
Stack trace:
#0 Z:\home\site.com\www\google-api-php-client\src\io\Google_REST.php(36):  Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 Z:\home\site.com\www\google-api-php-client\src\service\Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest))
#2 Z:\home\site.com\www\google-api-php-client\src\contrib\Google_DriveService.php(774): Google_ServiceResource->__call('update', Array)

这可能是图书馆的一个错误?
请帮忙。

4

1 回答 1

0

您的代码正在尝试更新文档所有者的权限并使该用户成为作家。云端硬盘文档必须只有一个所有者,因此您的请求无效。

于 2013-03-11T17:18:59.187 回答