Classic ASP Google Drive: List Replies for a Specified Comment on a File

Back to Index

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

Documentation: https://developers.google.com/drive/v3/reference/replies/list


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set rest = Server.CreateObject("Chilkat_9_5_0.Rest")

'   Provide a previously obtained OAuth2 access token.
set oauth2 = Server.CreateObject("Chilkat_9_5_0.OAuth2")
oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
success = rest.SetAuthOAuth2(oauth2)

success = rest.Connect("www.googleapis.com",443,1,1)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"

End If

success = rest.AddQueryParam("fields","replies")

set sbJson = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = rest.FullRequestNoBodySb("GET","/drive/v3/files/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments/AAAABg7tSGw/replies",sbJson)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"

End If

If (rest.ResponseStatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Received error response code: " & rest.ResponseStatusCode) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "Response body:") & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( sbJson.GetAsString()) & "</pre>"

End If

set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = json.LoadSb(sbJson)

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

i = 0
count_i = json.SizeOfArray("replies")
Do While i < count_i
    json.I = i
    kind = json.StringOf("replies[i].kind")
    id = json.StringOf("replies[i].id")
    createdTime = json.StringOf("replies[i].createdTime")
    modifiedTime = json.StringOf("replies[i].modifiedTime")
    authorKind = json.StringOf("replies[i].author.kind")
    authorDisplayName = json.StringOf("replies[i].author.displayName")
    authorPhotoLink = json.StringOf("replies[i].author.photoLink")
    authorMe = json.BoolOf("replies[i].author.me")
    htmlContent = json.StringOf("replies[i].htmlContent")
    content = json.StringOf("replies[i].content")
    deleted = json.BoolOf("replies[i].deleted")
    action = json.StringOf("replies[i].action")
    i = i + 1
Loop

Response.Write "<pre>" & Server.HTMLEncode( "Example Completed.") & "</pre>"

%>
</body>
</html>

Sample JSON Response Body

{
  "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"
    }
  ]
}