Is there any way we could create a folder on google drive using PHP? I've been searching all the web for the last 72 hours with no results. What do you think guys? Thanks !
Here is an updated method using the Google Drive API v3 and an OAuth access token:
$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);