【发布时间】:2022-01-20 10:59:31
【问题描述】:
当我成功运行“https://www.googleapis.com/drive/v3/files”时
但是,如果我尝试“https://www.googleapis.com/drive/v3/files/{fileId}/copy”,它会返回 404 错误
- 仔细检查了“fileId”。
- 已清除缓存并尝试但无法正常工作
- 已检查范围权限...
- 范围是 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive.photos.readonly'
同样的例子,如果我尝试“Drive Explorer Try Now”,它也可以正常工作。那到底是怎么回事,想不通
$url = 'https://www.googleapis.com/drive/v3/files/1ZYyl0MzfWy_V5Io3N0BTsF19pNiX7s23BqYPbQKplvU/copy';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '. $access_token));
$data = json_decode(curl_exec($ch), true);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code != 200)
throw new Exception('Error : Failed');
return $data;
【问题讨论】:
-
您只包含了 GET 的代码,我可以看到您的复制方法的代码吗?
标签: php curl google-drive-api google-docs google-docs-api