PHP CODE FOR CREATING A NEW FOLDER IN GOOGLE DRIVE API
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
require_once 'google-api-php-client/src/contrib/Google_Oauth2Service.php';
$client = new Google_Client();
// Get your credentials from the APIs Console
//$client->setApplicationName('Google+ PHP Starter Application');
$client->setClientId('your client id');
$client->setClientSecret('your client secret id');
$client->setRedirectUri('your redirect uri');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
$client->setAccessToken(file_get_contents('conf.json'));
if ($client->getAccessToken()) {
//It means that I have the right to manipulate whatever service
// Choose the service you want to use
$service = new Google_DriveService($client);
$file = new Google_DriveFile();
$file->setTitle('test'); //name of the folder
$file->setDescription('A test folder');
$file->setMimeType('application/vnd.google-apps.folder');
$createdFile = $service->files->insert($file, array(
'mimeType' => 'application/vnd.google-apps.folder',
));
// print_r($createdFile);
print "folder created sucessfully";
echo "folder id is" . $createdFile->id;
}
require_once 'google-api-php-client/src/Google_Client.php';
ReplyDeletewhere are these files???
i want this file...