Visual FoxPro Google Drive: Get Starting pageToken for Listing Future Changes

Back to Index

Gets the starting pageToken for listing future changes.

Documentation: https://developers.google.com/drive/v3/reference/changes/getStartPageToken


LOCAL loRest
LOCAL lnSuccess
LOCAL loOauth2
LOCAL loSbJson
LOCAL loJson
LOCAL lcKind
LOCAL lcStartPageToken

loRest = CreateObject('Chilkat_9_5_0.Rest')

*   Provide a previously obtained OAuth2 access token.
loOauth2 = CreateObject('Chilkat_9_5_0.OAuth2')
loOauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
loRest.SetAuthOAuth2(loOauth2)

lnSuccess = loRest.Connect("www.googleapis.com",443,1,1)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loOauth2
    CANCEL
ENDIF

loRest.AddQueryParam("teamDriveId","0AEd3EhGff2SaUk9PVA")
loRest.AddQueryParam("supportsTeamDrives","true")

loSbJson = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/drive/v3/changes/startPageToken",loSbJson)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loOauth2
    RELEASE loSbJson
    CANCEL
ENDIF

IF (loRest.ResponseStatusCode <> 200) THEN
    ? "Received error response code: " + STR(loRest.ResponseStatusCode)
    ? "Response body:"
    ? loSbJson.GetAsString()
    RELEASE loRest
    RELEASE loOauth2
    RELEASE loSbJson
    CANCEL
ENDIF

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.LoadSb(loSbJson)

*  The following code parses the JSON response.
*  A sample JSON response is shown below the sample code.

lcKind = loJson.StringOf("kind")
lcStartPageToken = loJson.StringOf("startPageToken")

? "Example Completed."

RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
RELEASE loJson

Sample JSON Response Body

{
  "kind": "drive#startPageToken",
  "startPageToken": "13"
}