我需要使用getIdForEmail方法来管理驱动文件的权限,在文档中有一个使用php客户端库的例子,但是浏览源代码它似乎还没有实现。在将其添加到发行版或可以添加(到Google_DriveService.php)的补丁之前,是否有解决方法?
使用最新版本的php client library 0.6.6。
编辑:这个问题的一个不太方便的解决办法是在用户第一次连接时获取权限id,并将其保存到应用程序的数据库中以供以后使用。尽管对于许多应用程序来说,无论用户是否经过身份验证,都可以用电子邮件地址交换权限id,这会更干净。
EDIT2:已检查0.6.7版仍然没有getIdForEmail函数。
发布于 2013-11-24 02:29:50
该函数确实存在于此处
因此在DriveService.php文件中添加
/**
* Returns the permission ID for an email address. (permissions.getIdForEmail)
*
* @param string $email The email address for which to return a permission ID
* @param array $optParams Optional parameters.
* @return Google_PermissionId
*/
public function getIdForEmail($email, $optParams = array()) {
$params = array('email' => $email);
$params = array_merge($params, $optParams);
$data = $this->__call('getIdForEmail', array($params));
if ($this->useObjects()) {
return new Google_PermissionId($data);
} else {
return $data;
}
}在Google_PermissionsServiceResource类中
然后替换以$this->permissions开头的行
使用
$this->permissions = new Google_PermissionsServiceResource($this, $this->serviceName, 'permissions', json_decode('{"methods": {"delete": {"id": "drive.permissions.delete", "path": "files/{fileId}/permissions/{permissionId}", "httpMethod": "DELETE", "parameters": {"fileId": {"type": "string", "required": true, "location": "path"}, "permissionId": {"type": "string", "required": true, "location": "path"}}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"]}, "get": {"id": "drive.permissions.get", "path": "files/{fileId}/permissions/{permissionId}", "httpMethod": "GET", "parameters": {"fileId": {"type": "string", "required": true, "location": "path"}, "permissionId": {"type": "string", "required": true, "location": "path"}}, "response": {"$ref": "Permission"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly"]}, "getIdForEmail": {"id": "drive.permissions.getIdForEmail", "path": "permissionIds/{email}", "httpMethod": "GET", "parameters": {"email": {"type": "string", "required": true, "location": "path"}}, "response": {"$ref": "PermissionId"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly"]}, "insert": {"id": "drive.permissions.insert", "path": "files/{fileId}/permissions", "httpMethod": "POST", "parameters": {"emailMessage": {"type": "string", "location": "query"}, "fileId": {"type": "string", "required": true, "location": "path"}, "sendNotificationEmails": {"type": "boolean", "default": "true", "location": "query"}}, "request": {"$ref": "Permission"}, "response": {"$ref": "Permission"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"]}, "list": {"id": "drive.permissions.list", "path": "files/{fileId}/permissions", "httpMethod": "GET", "parameters": {"fileId": {"type": "string", "required": true, "location": "path"}}, "response": {"$ref": "PermissionList"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly"]}, "patch": {"id": "drive.permissions.patch", "path": "files/{fileId}/permissions/{permissionId}", "httpMethod": "PATCH", "parameters": {"fileId": {"type": "string", "required": true, "location": "path"}, "permissionId": {"type": "string", "required": true, "location": "path"}, "transferOwnership": {"type": "boolean", "default": "false", "location": "query"}}, "request": {"$ref": "Permission"}, "response": {"$ref": "Permission"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"]}, "update": {"id": "drive.permissions.update", "path": "files/{fileId}/permissions/{permissionId}", "httpMethod": "PUT", "parameters": {"fileId": {"type": "string", "required": true, "location": "path"}, "permissionId": {"type": "string", "required": true, "location": "path"}, "transferOwnership": {"type": "boolean", "default": "false", "location": "query"}}, "request": {"$ref": "Permission"}, "response": {"$ref": "Permission"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"]}}}', true));更新:看起来新版本的API client (1.0) https://github.com/google/google-api-php-client支持这一点。
https://stackoverflow.com/questions/19092811
复制相似问题