Google Drive API副本() - 404错误 [英] Google Drive API copy() - 404 error

查看:569
本文介绍了Google Drive API副本() - 404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP中使用Google Drive API来管理任何文件(插入,删除,复制..)。
现在我需要在驱动器文件夹中创建一个文件的副本(插入工作正常)。
我的代码与Google 参考。我使用搜索参数找到文件ID,然后调用该函数:

I'm using Google Drive API in PHP to manage any files (insert, delete, copy..).
Now I need to create a copy of a file in drive folder (insert work fine).
My code is the same of Google reference. I'm find the file ID with search parameters and then call the function:

$parameters = array();
$parameters['q'] = "title = '".$title."' and mimeType = 'application/vnd.google-apps.spreadsheet'";
$files = $service->files->listFiles($parameters);
if (count($files['items'])>0){
    $fileId = $files['items'][0]['id']; // unique file name
    $copiedFile = new Google_Service_Drive_DriveFile();
    $copiedFile->setTitle("copied_file");
    $service->files->copy($fileId, $copiedFile);
}

但是当我调用copy()时出现这个错误:

but when I call copy() I got this error:

 Error calling POST https://www.googleapis.com/drive/v2/files/1adQjO5ABcbTai3GAEU3RBRHGi8u0_7DlaZfgWywxvqk/copy: (404) File not found: 16bRhq0E_OqYQlTys1oFu1vVeAjWl1P_non2-Z3lLdb8

这是复制文件的正确ID:

This is the right id of the file to copy:

1adQjO5ABcbTai3GAEU3RBRHGi8u0_7DlaZfgWywxvqk

但这是什么id:

but what's this id:

16bRhq0E_OqYQlTys1oFu1vVeAjWl1P_non2

我该如何解决它?

推荐答案

现在它可以工作。我从我的应用程序注销(并从谷歌帐户权限删除):当我登录谷歌OAuth请求新的权限,它工作正常。

Now It works. I logout from my application (and delete from google account permission): when I logged in google OAuth request new permission and It work fine.

这篇关于Google Drive API副本() - 404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆