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) ChartURL - Create a Signed URLDemonstrates how to create a signed URL for ChartURL.
integer li_rc oleobject loo_Crypt string ls_Key string ls_Token string ls_Slug string ls_Data oleobject loo_Json string ls_Sig oleobject loo_SbUrl // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Crypt = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") if li_rc < 0 then destroy loo_Crypt MessageBox("Error","Connecting to COM object failed") return end if // Example key: "dek-d7a46236eda961a6c3c18ffcc6b077ba87d27e9ae85f7842c6d427c265dd5f69d5131308d93332353d4a55a4b1160fcf516515a4a9f0aa50fbf2d7a2e7d0f1c5" ls_Key = "charturl-sign-encrypt-key" // Example token: "dt-RwYN" ls_Token = "charturl-token" ls_Slug = "weekly-activity" ls_Data = "{ ~"options~": {~"data~": {~"columns~": [[~"This Week~",10,13],[~"Last Week~",9,5]]}}}" loo_Crypt.HashAlgorithm = "SHA256" loo_Crypt.MacAlgorithm = "HMAC" loo_Crypt.SetMacKeyString(ls_Key) loo_Crypt.EncodingMode = "base64" 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.Load(ls_Data) Write-Debug "json = " + loo_Json.Emit() ls_Sig = loo_Crypt.MacStringENC(loo_Json.Emit()) loo_SbUrl = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbUrl.ConnectToNewObject("Chilkat.StringBuilder") loo_SbUrl.Append("https://charturl.com/i/") loo_SbUrl.Append(ls_Token) loo_SbUrl.Append("/") loo_SbUrl.Append(ls_Slug) loo_SbUrl.Append("?d=") loo_SbUrl.Append(loo_Crypt.EncodeString(loo_Json.Emit(),"utf-8","url")) loo_SbUrl.Append("&s=") loo_SbUrl.Append(loo_Crypt.EncodeString(ls_Sig,"utf-8","url")) Write-Debug "Signed URL: " + loo_SbUrl.GetAsString() destroy loo_Crypt destroy loo_Json destroy loo_SbUrl |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.