php - 使用 google drive api v3 复制文件返回“提供的文件 ID 不可用。”
问题描述
当我尝试使用 google drive api 复制文件时出现错误。有没有我缺少的参数?这是我得到的错误:
{
"error":{
"errors":[
{
"domain":"global",
"reason":"fileIdNotUsable",
"message":"The provided file ID is not usable.",
"locationType":"other",
"location":"file.id"
}
],
"code":400,
"message":"The provided file ID is not usable."
}
}
这是我的代码:
$client = new \Google_Client();
$client->setClientId(env('GOOGLE_DRIVE_CLIENT_ID'));
$client->setClientSecret(env('GOOGLE_DRIVE_CLIENT_SECRET'));
$client->refreshToken(env('GOOGLE_DRIVE_REFRESH_TOKEN'));
$service = new \Google_Service_Drive($client);
$optParams = array(
'pageSize' => 10,
'fields' => 'nextPageToken, files(id, name)'
);
$files = $service->files->listFiles($optParams);
foreach($files as $value){
if($value->mimeType != 'application/vnd.google-apps.folder'){
$service->files->copy($value->id, $value);
}
}
解决方案
推荐阅读
- html - 降价内容未反映在我的 html 模板 ( )
- reactjs - 快照和调试输出之间的反应测试库差异
- python - 为什么 Python 中有不适当的 Listing of Sort 方法?
- flutter - 颤振:DioError [DioErrorType.response]:Http状态错误[400]
- android - Json 图像未在 kotlin 中显示
- laravel - Laravel Echo 不听广播
- amazon-web-services - 域提供商中服务器 IP 的运行时 DNS 条目
- c# - 比较 gameObject 的变换并移除重复
- java - 在Android中将android Android图标转换为位图
- .net - 在 Visual Studio 2019 中找不到 SDK