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
(SQL Server) ChartURL - Create a Signed URLDemonstrates how to create a signed URL for ChartURL.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @sTmp1 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @crypt int -- Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Example key: "dek-d7a46236eda961a6c3c18ffcc6b077ba87d27e9ae85f7842c6d427c265dd5f69d5131308d93332353d4a55a4b1160fcf516515a4a9f0aa50fbf2d7a2e7d0f1c5" DECLARE @key nvarchar(4000) SELECT @key = 'charturl-sign-encrypt-key' -- Example token: "dt-RwYN" DECLARE @token nvarchar(4000) SELECT @token = 'charturl-token' DECLARE @slug nvarchar(4000) SELECT @slug = 'weekly-activity' DECLARE @data nvarchar(4000) SELECT @data = '{ "options": {"data": {"columns": [["This Week",10,13],["Last Week",9,5]]}}}' EXEC sp_OASetProperty @crypt, 'HashAlgorithm', 'SHA256' EXEC sp_OASetProperty @crypt, 'MacAlgorithm', 'HMAC' DECLARE @success int EXEC sp_OAMethod @crypt, 'SetMacKeyString', @success OUT, @key EXEC sp_OASetProperty @crypt, 'EncodingMode', 'base64' DECLARE @json int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT EXEC sp_OAMethod @json, 'Load', @success OUT, @data EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT 'json = ' + @sTmp0 DECLARE @sig nvarchar(4000) EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT EXEC sp_OAMethod @crypt, 'MacStringENC', @sig OUT, @sTmp0 DECLARE @sbUrl int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbUrl OUT EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, 'https://charturl.com/i/' EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, @token EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, '/' EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, @slug EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, '?d=' EXEC sp_OAMethod @json, 'Emit', @sTmp1 OUT EXEC sp_OAMethod @crypt, 'EncodeString', @sTmp0 OUT, @sTmp1, 'utf-8', 'url' EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, @sTmp0 EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, '&s=' EXEC sp_OAMethod @crypt, 'EncodeString', @sTmp0 OUT, @sig, 'utf-8', 'url' EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, @sTmp0 EXEC sp_OAMethod @sbUrl, 'GetAsString', @sTmp0 OUT PRINT 'Signed URL: ' + @sTmp0 EXEC @hr = sp_OADestroy @crypt EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @sbUrl END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.