Sample code for 30+ languages & platforms
Xbase++

Empty Trash

See more Google Drive Examples

Permanently deletes all of the user's trashed files.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oGAuth
LOCAL oRest
LOCAL nBAutoReconnect
LOCAL cJsonResponse

nSuccess := 0

nSuccess := 1

//  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.

oGAuth := CreateObject("Chilkat.AuthGoogle")
oGAuth:AccessToken := "GOOGLE-DRIVE-ACCESS-TOKEN"

oRest := CreateObject("Chilkat.Rest")

//  Connect using TLS.
nBAutoReconnect := 1
nSuccess := oRest:Connect("www.googleapis.com", 443, 1, nBAutoReconnect)

//  Provide the authentication credentials (i.e. the access token)
oRest:SetAuthGoogle(oGAuth)

cJsonResponse := oRest:FullRequestNoBody("DELETE", "/drive/v3/files/trash")
IF (oRest:LastMethodSuccess != 1)
    ? oRest:LastErrorText
    oGAuth:destroy()
    oRest:destroy()
    RETURN
ENDIF

//  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 (oRest:ResponseStatusCode != 204)
    ? "response status code = " + Str(oRest:ResponseStatusCode)
    ? "response status text = " + oRest:ResponseStatusText
    ? "response header: " + oRest:ResponseHeader
    ? "response JSON: " + cJsonResponse
    oGAuth:destroy()
    oRest:destroy()
    RETURN
ENDIF

? "Trash Emptied!"

oGAuth:destroy()
oRest:destroy()