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
(PowerBuilder) Create a Temporary Public Link to a DropBox FileGet a temporary link to stream content of a file. This link will expire in four hours and afterwards you will get 410 Gone. For more information, see https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link
integer li_rc oleobject loo_Http integer li_Success oleobject loo_Json oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_Template_id integer j integer li_Count_j string ls_Name string ls_Value string ls_MetadataName string ls_MetadataId string ls_MetadataClient_modified string ls_MetadataServer_modified string ls_MetadataRev integer li_MetadataSize string ls_MetadataPath_lower string ls_MetadataPath_display integer li_MetadataSharing_infoRead_only string ls_MetadataSharing_infoParent_shared_folder_id string ls_MetadataSharing_infoModified_by integer li_MetadataIs_downloadable integer li_MetadataHas_explicit_shared_members string ls_MetadataContent_hash string ls_Link integer i integer li_Count_i // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Implements the following CURL command: // curl -X POST https://api.dropboxapi.com/2/files/get_temporary_link \ // --header "Authorization: Bearer DROPBOX_ACCESS_TOKEN" \ // --header "Content-Type: application/json" \ // --data "{\"path\": \"/video.mp4\"}" // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "path": "/video.mp4" // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("path","/video.mp4") loo_Http.SetRequestHeader("Authorization","Bearer DROPBOX_ACCESS_TOKEN") loo_Http.SetRequestHeader("Content-Type","application/json") loo_Resp = loo_Http.PostJson3("https://api.dropboxapi.com/2/files/get_temporary_link","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Json return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_Resp // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "metadata": { // "name": "Prime_Numbers.txt", // "id": "id:a4ayc_80_OEAAAAAAAAAXw", // "client_modified": "2015-05-12T15:50:38Z", // "server_modified": "2015-05-12T15:50:38Z", // "rev": "a1c10ce0dd78", // "size": 7212, // "path_lower": "/homework/math/prime_numbers.txt", // "path_display": "/Homework/math/Prime_Numbers.txt", // "sharing_info": { // "read_only": true, // "parent_shared_folder_id": "84528192421", // "modified_by": "dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc" // }, // "is_downloadable": true, // "property_groups": [ // { // "template_id": "ptid:1a5n2i6d3OYEAAAAAAAAAYa", // "fields": [ // { // "name": "Security Policy", // "value": "Confidential" // } // ] // } // ], // "has_explicit_shared_members": false, // "content_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" // }, // "link": "https://dl.dropboxusercontent.com/apitl/1/YXNkZmFzZGcyMzQyMzI0NjU2NDU2NDU2" // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_MetadataName = loo_JResp.StringOf("metadata.name") ls_MetadataId = loo_JResp.StringOf("metadata.id") ls_MetadataClient_modified = loo_JResp.StringOf("metadata.client_modified") ls_MetadataServer_modified = loo_JResp.StringOf("metadata.server_modified") ls_MetadataRev = loo_JResp.StringOf("metadata.rev") li_MetadataSize = loo_JResp.IntOf("metadata.size") ls_MetadataPath_lower = loo_JResp.StringOf("metadata.path_lower") ls_MetadataPath_display = loo_JResp.StringOf("metadata.path_display") li_MetadataSharing_infoRead_only = loo_JResp.BoolOf("metadata.sharing_info.read_only") ls_MetadataSharing_infoParent_shared_folder_id = loo_JResp.StringOf("metadata.sharing_info.parent_shared_folder_id") ls_MetadataSharing_infoModified_by = loo_JResp.StringOf("metadata.sharing_info.modified_by") li_MetadataIs_downloadable = loo_JResp.BoolOf("metadata.is_downloadable") li_MetadataHas_explicit_shared_members = loo_JResp.BoolOf("metadata.has_explicit_shared_members") ls_MetadataContent_hash = loo_JResp.StringOf("metadata.content_hash") ls_Link = loo_JResp.StringOf("link") i = 0 li_Count_i = loo_JResp.SizeOfArray("metadata.property_groups") do while i < li_Count_i loo_JResp.I = i ls_Template_id = loo_JResp.StringOf("metadata.property_groups[i].template_id") j = 0 li_Count_j = loo_JResp.SizeOfArray("metadata.property_groups[i].fields") do while j < li_Count_j loo_JResp.J = j ls_Name = loo_JResp.StringOf("metadata.property_groups[i].fields[j].name") ls_Value = loo_JResp.StringOf("metadata.property_groups[i].fields[j].value") j = j + 1 loop i = i + 1 loop destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.