我像这样上传文件:
if (isset($_FILES[$name])) {
$service = new Google_DriveService($client);
//Insert a file
$file = new Google_DriveFile();
$file->setTitle($_FILES[$name]['name']);
$file->setMimeType($_FILES[$name]['type']);
$file->setParents(array('imgs'));
$insertedFile = $service->files->insert($file, array(
'data' => file_get_contents($_FILES[$name]['tmp_name']),
'mimeType' => $_FILES[$name]['type']
));
return $insertedFile;
}
得到insertedFile
这样的:
Array
(
[kind] => drive#file
[id] => 1sASTlgG7IFzcZyTUihp53uJbppFtxLs_GK_V2jYwapE
[etag] => "vGmlhiWxP02tugPmRvLynwC_A0Y/MTM2NjE4NTYyNzQwOQ"
[selfLink] => https://www.googleapis.com/drive/v2/files/1sASTlgG7IFzcZyTUihp53uJbppFtxLs_GK_V2jYwapE
[alternateLink] => ...
但是当我去 selfLink 时,我得到一个错误
{
...
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
在没有任何授权的情况下获取上传文件的正确方法是什么?看起来文件只能通过 API 获得。