Lists the replies for a particular comment on a file. The file is specified by file ID. This example lists replies for comment (id="AAAABg7tSGw") on the file having id = "0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw".
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"
IncludeFile "CkOAuth2.pb"
Procedure ChilkatExample()
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Provide a previously obtained OAuth2 access token.
oauth2.i = CkOAuth2::ckCreate()
If oauth2.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkOAuth2::setCkAccessToken(oauth2, "OAUTH2_ACCESS_TOKEN")
CkRest::ckSetAuthOAuth2(rest,oauth2)
success = CkRest::ckConnect(rest,"www.googleapis.com",443,1,1)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
ProcedureReturn
EndIf
CkRest::ckAddQueryParam(rest,"fields","replies")
sbJson.i = CkStringBuilder::ckCreate()
If sbJson.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkRest::ckFullRequestNoBodySb(rest,"GET","/drive/v3/files/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments/AAAABg7tSGw/replies",sbJson)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
CkStringBuilder::ckDispose(sbJson)
ProcedureReturn
EndIf
If CkRest::ckResponseStatusCode(rest) <> 200
Debug "Received error response code: " + Str(CkRest::ckResponseStatusCode(rest))
Debug "Response body:"
Debug CkStringBuilder::ckGetAsString(sbJson)
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
CkStringBuilder::ckDispose(sbJson)
ProcedureReturn
EndIf
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(json,sbJson)
; The following code parses the JSON response.
; A sample JSON response is shown below the sample code.
i.i
count_i.i
kind.s
id.s
createdTime.s
modifiedTime.s
authorKind.s
authorDisplayName.s
authorPhotoLink.s
authorMe.i
htmlContent.s
content.s
deleted.i
action.s
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"replies")
While i < count_i
CkJsonObject::setCkI(json, i)
kind = CkJsonObject::ckStringOf(json,"replies[i].kind")
id = CkJsonObject::ckStringOf(json,"replies[i].id")
createdTime = CkJsonObject::ckStringOf(json,"replies[i].createdTime")
modifiedTime = CkJsonObject::ckStringOf(json,"replies[i].modifiedTime")
authorKind = CkJsonObject::ckStringOf(json,"replies[i].author.kind")
authorDisplayName = CkJsonObject::ckStringOf(json,"replies[i].author.displayName")
authorPhotoLink = CkJsonObject::ckStringOf(json,"replies[i].author.photoLink")
authorMe = CkJsonObject::ckBoolOf(json,"replies[i].author.me")
htmlContent = CkJsonObject::ckStringOf(json,"replies[i].htmlContent")
content = CkJsonObject::ckStringOf(json,"replies[i].content")
deleted = CkJsonObject::ckBoolOf(json,"replies[i].deleted")
action = CkJsonObject::ckStringOf(json,"replies[i].action")
i = i + 1
Wend
Debug "Example Completed."
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
CkStringBuilder::ckDispose(sbJson)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure
{
"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"
}
]
}