Lists the comment on a file. The file is specified by file ID. This example lists comments on the file having id = "0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw".
LOCAL loRest
LOCAL lnSuccess
LOCAL loOauth2
LOCAL loSbJson
LOCAL loJson
LOCAL i
LOCAL lnCount_i
LOCAL lcKind
LOCAL lcId
LOCAL lcCreatedTime
LOCAL lcModifiedTime
LOCAL lcAuthorKind
LOCAL lcAuthorDisplayName
LOCAL lcAuthorPhotoLink
LOCAL lnAuthorMe
LOCAL lcHtmlContent
LOCAL lcContent
LOCAL lnDeleted
LOCAL lnResolved
LOCAL j
LOCAL lnCount_j
LOCAL lcAction
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("fields","comments")
loSbJson = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/drive/v3/files/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments",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.
i = 0
lnCount_i = loJson.SizeOfArray("comments")
DO WHILE i < lnCount_i
loJson.I = i
lcKind = loJson.StringOf("comments[i].kind")
lcId = loJson.StringOf("comments[i].id")
lcCreatedTime = loJson.StringOf("comments[i].createdTime")
lcModifiedTime = loJson.StringOf("comments[i].modifiedTime")
lcAuthorKind = loJson.StringOf("comments[i].author.kind")
lcAuthorDisplayName = loJson.StringOf("comments[i].author.displayName")
lcAuthorPhotoLink = loJson.StringOf("comments[i].author.photoLink")
lnAuthorMe = loJson.BoolOf("comments[i].author.me")
lcHtmlContent = loJson.StringOf("comments[i].htmlContent")
lcContent = loJson.StringOf("comments[i].content")
lnDeleted = loJson.BoolOf("comments[i].deleted")
lnResolved = loJson.BoolOf("comments[i].resolved")
j = 0
lnCount_j = loJson.SizeOfArray("comments[i].replies")
DO WHILE j < lnCount_j
loJson.J = j
lcKind = loJson.StringOf("comments[i].replies[j].kind")
lcId = loJson.StringOf("comments[i].replies[j].id")
lcCreatedTime = loJson.StringOf("comments[i].replies[j].createdTime")
lcModifiedTime = loJson.StringOf("comments[i].replies[j].modifiedTime")
lcAuthorKind = loJson.StringOf("comments[i].replies[j].author.kind")
lcAuthorDisplayName = loJson.StringOf("comments[i].replies[j].author.displayName")
lcAuthorPhotoLink = loJson.StringOf("comments[i].replies[j].author.photoLink")
lnAuthorMe = loJson.BoolOf("comments[i].replies[j].author.me")
lcHtmlContent = loJson.StringOf("comments[i].replies[j].htmlContent")
lcContent = loJson.StringOf("comments[i].replies[j].content")
lnDeleted = loJson.BoolOf("comments[i].replies[j].deleted")
lcAction = loJson.StringOf("comments[i].replies[j].action")
j = j + 1
ENDDO
i = i + 1
ENDDO
? "Example Completed."
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
RELEASE loJson
{
"comments": [
{
"kind": "drive#comment",
"id": "AAAABg7vWfw",
"createdTime": "2017-11-13T17:51:57.906Z",
"modifiedTime": "2017-11-13T17:51:57.906Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the 2nd test comment about this file...",
"content": "This is the 2nd test comment about this file...",
"deleted": false,
"resolved": false,
"replies": [
]
},
{
"kind": "drive#comment",
"id": "AAAABg7tSGw",
"createdTime": "2017-11-13T17:43:05.735Z",
"modifiedTime": "2017-11-13T18:25:11.828Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is a test comment about this file...",
"content": "This is a test comment about this file...",
"deleted": false,
"resolved": true,
"replies": [
{
"kind": "drive#reply",
"id": "AAAABg76H9g",
"createdTime": "2017-11-13T18:24:12.782Z",
"modifiedTime": "2017-11-13T18:24:12.782Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the first reply to a comment.",
"content": "This is the first reply to a comment.",
"deleted": false,
"action": "reopen"
},
{
"kind": "drive#reply",
"id": "AAAABg76H9k",
"createdTime": "2017-11-13T18:24:45.085Z",
"modifiedTime": "2017-11-13T18:24:45.085Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the second reply to a comment.",
"content": "This is the second reply to a comment.",
"deleted": false,
"action": "resolve"
},
{
"kind": "drive#reply",
"id": "AAAABg76H9o",
"createdTime": "2017-11-13T18:25:11.828Z",
"modifiedTime": "2017-11-13T18:25:11.828Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the third reply to a comment.",
"content": "This is the third reply to a comment.",
"deleted": false,
"action": "resolve"
}
]
}
]
}