在google drive php中创建文件夹
我们可以用PHP在谷歌硬盘上创建一个文件夹吗?在过去的72小时里,我一直在搜索所有的网页,但没有结果。 你们觉得呢,伙计们? 谢谢 创建文件夹: “在驱动器API中,文件夹本质上是一个文件,由特殊文件夹MIME类型应用程序/vnd.google-apps.folder标识。您可以通过插入具有此MIME类型和文件夹标题的文件来创建新文件夹。设置文件夹标题时不要包含扩展名 要创建特定文件夹的子文件夹,请在文件的父属性中指定正确的ID。例如,要在ID值为0ADK06pfg的“images”文件夹中创建文件夹“pets”: 资料来源:在google drive php中创建文件夹,php,directory,google-drive-api,google-drive-realtime-api,Php,Directory,Google Drive Api,Google Drive Realtime Api,我们可以用PHP在谷歌硬盘上创建一个文件夹吗?在过去的72小时里,我一直在搜索所有的网页,但没有结果。 你们觉得呢,伙计们? 谢谢 创建文件夹: “在驱动器API中,文件夹本质上是一个文件,由特殊文件夹MIME类型应用程序/vnd.google-apps.folder标识。您可以通过插入具有此MIME类型和文件夹标题的文件来创建新文件夹。设置文件夹标题时不要包含扩展名 要创建特定文件夹的子文件夹,请在文件的父属性中指定正确的ID。例如,要在ID值为0ADK06pfg的“images”文件夹中创建
示例:以下是使用Google Drive API v3和OAuth访问令牌的更新方法:
$googleClient = new \Google_Client();
$googleClient->setApplicationName('My App');
$googleClient->setAccessToken(env('GOOGLE_OAUTH_ACCESS_TOKEN'));
$googleClient->setClientId(env('GOOGLE_APP_ID'));
$googleClient->setClientSecret(env('GOOGLE_APP_SECRET'));
if ($googleClient->isAccessTokenExpired()) {
$googleClient->fetchAccessTokenWithRefreshToken();
}
$api = new \Google_Service_Drive($client);
$file = new \Google_Service_Drive_DriveFile();
$file->setName('Folder Name');
$file->setMimeType('application/vnd.google-apps.folder');
$folder = $api->files->create($file);
你读过这个吗?或者这个:谢谢你,兄弟,这真的很简单,我记得在浏览API时读过这篇文章,但没有给予它那么重要。再次感谢保罗,成功了:)
$googleClient = new \Google_Client();
$googleClient->setApplicationName('My App');
$googleClient->setAccessToken(env('GOOGLE_OAUTH_ACCESS_TOKEN'));
$googleClient->setClientId(env('GOOGLE_APP_ID'));
$googleClient->setClientSecret(env('GOOGLE_APP_SECRET'));
if ($googleClient->isAccessTokenExpired()) {
$googleClient->fetchAccessTokenWithRefreshToken();
}
$api = new \Google_Service_Drive($client);
$file = new \Google_Service_Drive_DriveFile();
$file->setName('Folder Name');
$file->setMimeType('application/vnd.google-apps.folder');
$folder = $api->files->create($file);