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
(PureBasic) ChartURL - Create a Signed URLDemonstrates how to create a signed URL for ChartURL.
IncludeFile "CkStringBuilder.pb" IncludeFile "CkJsonObject.pb" IncludeFile "CkCrypt2.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. crypt.i = CkCrypt2::ckCreate() If crypt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Example key: "dek-d7a46236eda961a6c3c18ffcc6b077ba87d27e9ae85f7842c6d427c265dd5f69d5131308d93332353d4a55a4b1160fcf516515a4a9f0aa50fbf2d7a2e7d0f1c5" key.s = "charturl-sign-encrypt-key" ; Example token: "dt-RwYN" token.s = "charturl-token" slug.s = "weekly-activity" data.s = "{ " + Chr(34) + "options" + Chr(34) + ": {" + Chr(34) + "data" + Chr(34) + ": {" + Chr(34) + "columns" + Chr(34) + ": [[" + Chr(34) + "This Week" + Chr(34) + ",10,13],[" + Chr(34) + "Last Week" + Chr(34) + ",9,5]]}}}" CkCrypt2::setCkHashAlgorithm(crypt, "SHA256") CkCrypt2::setCkMacAlgorithm(crypt, "HMAC") CkCrypt2::ckSetMacKeyString(crypt,key) CkCrypt2::setCkEncodingMode(crypt, "base64") json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,data) Debug "json = " + CkJsonObject::ckEmit(json) sig.s = CkCrypt2::ckMacStringENC(crypt,CkJsonObject::ckEmit(json)) sbUrl.i = CkStringBuilder::ckCreate() If sbUrl.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbUrl,"https://charturl.com/i/") CkStringBuilder::ckAppend(sbUrl,token) CkStringBuilder::ckAppend(sbUrl,"/") CkStringBuilder::ckAppend(sbUrl,slug) CkStringBuilder::ckAppend(sbUrl,"?d=") CkStringBuilder::ckAppend(sbUrl,CkCrypt2::ckEncodeString(crypt,CkJsonObject::ckEmit(json),"utf-8","url")) CkStringBuilder::ckAppend(sbUrl,"&s=") CkStringBuilder::ckAppend(sbUrl,CkCrypt2::ckEncodeString(crypt,sig,"utf-8","url")) Debug "Signed URL: " + CkStringBuilder::ckGetAsString(sbUrl) CkCrypt2::ckDispose(crypt) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbUrl) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.