Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.js

Visual Basic 6.0 Examples

Async
Certificates
ECC
Email Object
Encryption
FTP
HTML-to-XML/Text
Gzip
HTTP
IMAP
JSON
MHT / HTML Email
PEM
PFX/P12
Java KeyStore (JKS)
POP3
RSA Encryption
MIME
REST
SCP
SMTP
Socket/SSL/TLS
SSH Key
SSH
SFTP
Stream
Tar Archive
XML
XMP
Zip

More Examples...
Google APIs
Google Cloud Storage
Azure Cloud Storage
Amazon S3 (new)
Google Drive
ASN.1
PRNG
Amazon S3
Bounced Email
CSV
Diffie-Hellman
DKIM / DomainKey
DSA
NTLM
QuickBooks

 

 

 

 

 

 

 

(Visual Basic 6.0) Dropbox: Access Your Own Account

To programmatically interact with your own Dropbox account, such as for uploading, downloading, listing files, etc., go to the Dropbox app console and create an application. Then generate an access token in the online app console as shown in the screenshot below. The access token does not expire, and can be used to access your own account from your own non-web application.

The example code, located below the screenshot, shows how to list the files in the root folder.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

'  This example requires the Chilkat API to have been previously unlocked.
'  See Global Unlock Sample for sample code.

Dim rest As New ChilkatRest

'  Connect to the www.dropbox.com endpoint.
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
Dim success As Long
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
    Text1.Text = Text1.Text & rest.LastErrorText & vbCrLf
    Exit Sub
End If

'  Note: Methods such as AddHeader, AppendString, AddBoolAt, etc.
'  technically return a success status, but the only reason for failure would be for out-of-memory.
success = rest.AddHeader("Content-Type","application/json")
success = rest.AddHeader("Authorization","Bearer DROPBOX_ACCESS_TOKEN")

Dim json As New ChilkatJsonObject
'  The root folder should be an empty string, not "/"
success = json.AppendString("path","")
success = json.AddBoolAt(-1,"recursive",0)
success = json.AddBoolAt(-1,"include_media_info",0)
success = json.AddBoolAt(-1,"include_deleted",0)
success = json.AddBoolAt(-1,"include_has_explicit_shared_members",0)

Dim responseStr As String
responseStr = rest.FullRequestString("POST","/2/files/list_folder",json.Emit())
If (rest.LastMethodSuccess <> 1) Then
    Text1.Text = Text1.Text & rest.LastErrorText & vbCrLf
    Exit Sub
End If

'  Success is indicated by a 200 response status code.
If (rest.ResponseStatusCode <> 200) Then
    '  Examine the request/response to see what happened.
    Text1.Text = Text1.Text & "response status code = " & rest.ResponseStatusCode & vbCrLf
    Text1.Text = Text1.Text & "response status text = " & rest.ResponseStatusText & vbCrLf
    Text1.Text = Text1.Text & "response header: " & rest.ResponseHeader & vbCrLf
    Text1.Text = Text1.Text & "response body (if any): " & responseStr & vbCrLf
    Text1.Text = Text1.Text & "---" & vbCrLf
    Text1.Text = Text1.Text & "LastRequestStartLine: " & rest.LastRequestStartLine & vbCrLf
    Text1.Text = Text1.Text & "LastRequestHeader: " & rest.LastRequestHeader & vbCrLf
    Exit Sub
End If

Dim jsonResponse As New ChilkatJsonObject
success = jsonResponse.Load(responseStr)

jsonResponse.EmitCompact = 0
Text1.Text = Text1.Text & jsonResponse.Emit() & vbCrLf

'  A sample JSON response is shown at the end of this example.
'  The following code iterates over the entries.
Dim numEntries As Long
numEntries = jsonResponse.SizeOfArray("entries")
Dim i As Long
i = 0
Do While i < numEntries
    jsonResponse.I = i
    Text1.Text = Text1.Text & "----" & vbCrLf
    Text1.Text = Text1.Text & "name: " & jsonResponse.StringOf("entries[i].name") & vbCrLf
    Text1.Text = Text1.Text & "path_lower: " & jsonResponse.StringOf("entries[i].path_lower") & vbCrLf
    Text1.Text = Text1.Text & "path_display: " & jsonResponse.StringOf("entries[i].path_display") & vbCrLf
    If (jsonResponse.HasMember("entries[i].sharing_info") = 1) Then
        Text1.Text = Text1.Text & "has sharing_info..." & vbCrLf
        Text1.Text = Text1.Text & "read_only: " & jsonResponse.StringOf("entries[i].sharing_info.read_only") & vbCrLf
        Text1.Text = Text1.Text & "shared_folder_id: " & jsonResponse.StringOf("entries[i].sharing_info.shared_folder_id") & vbCrLf
    End If

    If (jsonResponse.HasMember("entries[i].client_modified") = 1) Then
        '  Demonstrate how to parse a date/time:
        Dim ckdt As New CkDateTime
        success = ckdt.SetFromTimestamp(jsonResponse.StringOf("entries[i].client_modified"))
        '  The date/time can now be converted to many other formats, or the individual parts
        '  can be accessed.
        Dim bLocalDateTime As Long
        bLocalDateTime = 1
        Dim dt As DtObj
        Set dt = ckdt.GetDtObj(bLocalDateTime)
        Text1.Text = Text1.Text & dt.Year & "-" & dt.Month & "-" & dt.Day & vbCrLf

    End If

    i = i + 1
Loop

Text1.Text = Text1.Text & "Success." & vbCrLf


/*

{
  "entries": [
    {
      ".tag": "folder",
      "name": "chilkat Team Folder",
      "path_lower": "/chilkat team folder",
      "path_display": "/chilkat Team Folder",
      "id": "id:2VqX9RLr-JAAAAAAAAAAAQ",
      "shared_folder_id": "1210954290",
      "sharing_info": {
        "read_only": false,
        "shared_folder_id": "1210954290"
      }
    },
    {
      ".tag": "file",
      "name": "Get Started with Dropbox.pdf",
      "path_lower": "/get started with dropbox.pdf",
      "path_display": "/Get Started with Dropbox.pdf",
      "id": "id:oxE2oMDqH4AAAAAAAAAAAQ",
      "client_modified": "2016-05-07T11:47:47Z",
      "server_modified": "2016-05-07T11:47:47Z",
      "rev": "1483db13f",
      "size": 692088
    }
  ],
  "cursor": "AAEnZXciJyS4gzC_tlX6K2na4c8o7_09-dxmXKHpkPPyf3Kl0H4N-VYnz424nCrFOJuhMiM5_RgNAersumx9qe7NgCSdlppr80iFk0gf6vPlecM6SBtLcs6OYXL8ILWiZ62pfnOvgC3WKGlG6dqZ-VXH",
  "has_more": false
}

*/

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.