PHP
PHP
Empty Trash
See more Google Drive Examples
Permanently deletes all of the user's trashed files.Chilkat PHP Downloads
<?php
use Chilkat2\AuthGoogle;
use Chilkat2\Rest;
$success = false;
$success = true;
// It requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// This example uses a previously obtained access token having permission for the
// Google Drive scope.
$gAuth = new AuthGoogle();
$gAuth->AccessToken = 'GOOGLE-DRIVE-ACCESS-TOKEN';
$rest = new Rest();
// Connect using TLS.
$bAutoReconnect = true;
$rest->Connect('www.googleapis.com', 443, true, $bAutoReconnect);
// Provide the authentication credentials (i.e. the access token)
$rest->SetAuthGoogle($gAuth);
try {
$jsonResponse = $rest->FullRequestNoBody('DELETE', '/drive/v3/files/trash');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
// A successful response will have a status code equal to 204 and the response body is empty.
// (If not successful, then there should be a JSON response body with information..)
if ($rest->ResponseStatusCode != 204) {
echo 'response status code = ', $rest->ResponseStatusCode, "\n";
echo 'response status text = ', $rest->ResponseStatusText, "\n";
echo 'response header: ', $rest->ResponseHeader, "\n";
echo 'response JSON: ', $jsonResponse, "\n";
exit;
}
echo "Trash Emptied!\n";