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) BrickLink OAuth1 using Chilkat RESTSee more BrickLink ExamplesDemonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat REST. Note: This example requires Chilkat v9.5.0.91 or greater (due to adjustments made within Chilkat to support bricklink OAuth1 needs). For more information, see https://www.bricklink.com/v3/api.page?page=auth
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @oauth1 int -- Use "Chilkat_9_5_0.OAuth1" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.OAuth1', @oauth1 OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OASetProperty @oauth1, 'ConsumerKey', 'Your Consumer Key' EXEC sp_OASetProperty @oauth1, 'ConsumerSecret', 'Your Consumer Secret' EXEC sp_OASetProperty @oauth1, 'Token', 'Your OAuth1 Token' EXEC sp_OASetProperty @oauth1, 'TokenSecret', 'Your Token Secret' EXEC sp_OASetProperty @oauth1, 'SignatureMethod', 'HMAC-SHA1' DECLARE @success int DECLARE @rest int -- Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Rest', @rest OUT EXEC sp_OAMethod @rest, 'SetAuthOAuth1', @success OUT, @oauth1, 0 EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'api.bricklink.com', 443, 1, 1 IF @success = 0 BEGIN EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @oauth1 EXEC @hr = sp_OADestroy @rest RETURN END DECLARE @sbResponse int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponse OUT EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/api/store/v1/orders?direction=in', @sbResponse IF @success = 0 BEGIN EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @oauth1 EXEC @hr = sp_OADestroy @rest EXEC @hr = sp_OADestroy @sbResponse RETURN END EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT PRINT 'Response status code = ' + @iTmp0 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, 'LoadSb', @success OUT, @sbResponse EXEC sp_OASetProperty @json, 'EmitCompact', 0 EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @oauth1 EXEC @hr = sp_OADestroy @rest EXEC @hr = sp_OADestroy @sbResponse EXEC @hr = sp_OADestroy @json END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.