Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Dropbox: Access Your Own AccountTo 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.
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oRest = ObjCreate("Chilkat.Rest") ; Connect to the www.dropbox.com endpoint. Local $bTls = True Local $iPort = 443 Local $bAutoReconnect = True Local $bSuccess = $oRest.Connect("api.dropboxapi.com",$iPort,$bTls,$bAutoReconnect) If ($bSuccess <> True) Then ConsoleWrite($oRest.LastErrorText & @CRLF) Exit EndIf $oRest.AddHeader("Content-Type","application/json") $oRest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN") $oJson = ObjCreate("Chilkat.JsonObject") ; The root folder should be an empty string, not "/" $oJson.AppendString("path","") $oJson.AppendBool("recursive",False) $oJson.AppendBool("include_media_info",False) $oJson.AppendBool("include_deleted",False) $oJson.AppendBool("include_has_explicit_shared_members",False) Local $sResponseStr = $oRest.FullRequestString("POST","/2/files/list_folder",$oJson.Emit()) If ($oRest.LastMethodSuccess <> True) Then ConsoleWrite($oRest.LastErrorText & @CRLF) Exit EndIf ; Success is indicated by a 200 response status code. If ($oRest.ResponseStatusCode <> 200) Then ; Examine the request/response to see what happened. ConsoleWrite("response status code = " & $oRest.ResponseStatusCode & @CRLF) ConsoleWrite("response status text = " & $oRest.ResponseStatusText & @CRLF) ConsoleWrite("response header: " & $oRest.ResponseHeader & @CRLF) ConsoleWrite("response body (if any): " & $sResponseStr & @CRLF) ConsoleWrite("---" & @CRLF) ConsoleWrite("LastRequestStartLine: " & $oRest.LastRequestStartLine & @CRLF) ConsoleWrite("LastRequestHeader: " & $oRest.LastRequestHeader & @CRLF) Exit EndIf $oJsonResponse = ObjCreate("Chilkat.JsonObject") $oJsonResponse.Load($sResponseStr) $oJsonResponse.EmitCompact = False ConsoleWrite($oJsonResponse.Emit() & @CRLF) ; A sample JSON response is shown at the end of this example. ; The following code iterates over the entries. Local $iNumEntries = $oJsonResponse.SizeOfArray("entries") Local $i = 0 While $i < $iNumEntries $oJsonResponse.I = $i ConsoleWrite("----" & @CRLF) ConsoleWrite("name: " & $oJsonResponse.StringOf("entries[i].name") & @CRLF) ConsoleWrite("path_lower: " & $oJsonResponse.StringOf("entries[i].path_lower") & @CRLF) ConsoleWrite("path_display: " & $oJsonResponse.StringOf("entries[i].path_display") & @CRLF) If ($oJsonResponse.HasMember("entries[i].sharing_info") = True) Then ConsoleWrite("has sharing_info..." & @CRLF) ConsoleWrite("read_only: " & $oJsonResponse.StringOf("entries[i].sharing_info.read_only") & @CRLF) ConsoleWrite("shared_folder_id: " & $oJsonResponse.StringOf("entries[i].sharing_info.shared_folder_id") & @CRLF) EndIf If ($oJsonResponse.HasMember("entries[i].client_modified") = True) Then ; Demonstrate how to parse a date/time: $oCkdt = ObjCreate("Chilkat.CkDateTime") $bSuccess = $oCkdt.SetFromTimestamp($oJsonResponse.StringOf("entries[i].client_modified")) ; The date/time can now be converted to many other formats, or the individual parts ; can be accessed. Local $bLocalDateTime = True Local $oDt = $oCkdt.GetDtObj($bLocalDateTime) ConsoleWrite($oDt.Year & "-" & $oDt.Month & "-" & $oDt.Day & @CRLF) EndIf $i = $i + 1 Wend ConsoleWrite("Success." & @CRLF) ; { ; "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-2024 Chilkat Software, Inc. All Rights Reserved.