Classic ASP
Classic ASP
Dropbox: Get Space Usage
See more Dropbox Examples
Demonstrates how to get the Dropbox space usage information for the current user's account.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set rest = Server.CreateObject("Chilkat.Rest")
' Connect to the www.dropbox.com endpoint.
bTls = 1
port = 443
bAutoReconnect = 1
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
success = rest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN")
responseStr = rest.FullRequestNoBody("POST","/2/users/get_space_usage")
If (rest.LastMethodSuccess <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
' Success is indicated by a 200 response status code.
If (rest.ResponseStatusCode <> 200) Then
' Examine the request/response to see what happened.
Response.Write "<pre>" & Server.HTMLEncode( "response status code = " & rest.ResponseStatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "response status text = " & rest.ResponseStatusText) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "response header: " & rest.ResponseHeader) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "response body (if any): " & responseStr) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "---") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "LastRequestStartLine: " & rest.LastRequestStartLine) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "LastRequestHeader: " & rest.LastRequestHeader) & "</pre>"
Response.End
End If
set jsonResponse = Server.CreateObject("Chilkat.JsonObject")
success = jsonResponse.Load(responseStr)
jsonResponse.EmitCompact = 0
Response.Write "<pre>" & Server.HTMLEncode( jsonResponse.Emit()) & "</pre>"
' {
' "used": 3032115,
' "allocation": {
' ".tag": "individual",
' "allocated": 2147483648
' }
' }
'
%>
</body>
</html>