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) SMSAPI - Get User Account InformationGet a list of subusers. For more information, see https://www.smsapi.com/docs#10-user-accounts-administration
-- 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) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @http int -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Implements the following CURL command: -- curl -i -H "Authorization: Bearer token_api_oauth" \ -- -H "Content-Type: application/json" -X GET https://api.smsapi.com/subusers -- Use the following online tool to generate HTTP code from a CURL command -- Convert a cURL Command to HTTP Source Code -- Adds the "Authorization: Bearer token_api_oauth" header. EXEC sp_OASetProperty @http, 'AuthToken', 'token_api_oauth' EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json' DECLARE @sbResponseBody int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.smsapi.com/subusers', @sbResponseBody IF @success = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbResponseBody RETURN END DECLARE @jarrResp int -- Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarrResp OUT EXEC sp_OAMethod @jarrResp, 'LoadSb', @success OUT, @sbResponseBody EXEC sp_OASetProperty @jarrResp, 'EmitCompact', 0 PRINT 'Response Body:' EXEC sp_OAMethod @jarrResp, 'Emit', @sTmp0 OUT PRINT @sTmp0 DECLARE @respStatusCode int EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT PRINT 'Response Status Code = ' + @respStatusCode IF @respStatusCode >= 400 BEGIN PRINT 'Response Header:' EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT PRINT @sTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jarrResp RETURN END -- Sample JSON response: -- (Sample code for parsing the JSON response is shown below) -- [ -- { -- "id": "5A5359173738303F2F95B7E2", -- "username": "subuser1", -- "active": "true", -- "description": "null", -- "from_account": "10.0000", -- "per_month": "0" -- }, -- { -- "id": "5A5359173738303F2F95B7E2", -- "username": "subuser2", -- "active": "true", -- "description": "null", -- "from_account": "10.0000", -- "per_month": "0" -- } -- ] -- Sample code for parsing the JSON response... -- Use the following online tool to generate parsing code from sample JSON: -- Generate Parsing Code from JSON DECLARE @json int DECLARE @id nvarchar(4000) DECLARE @username nvarchar(4000) DECLARE @active nvarchar(4000) DECLARE @description nvarchar(4000) DECLARE @from_account nvarchar(4000) DECLARE @per_month nvarchar(4000) DECLARE @i int SELECT @i = 0 DECLARE @count_i int EXEC sp_OAGetProperty @jarrResp, 'Size', @count_i OUT WHILE @i < @count_i BEGIN EXEC sp_OAMethod @jarrResp, 'ObjectAt', @json OUT, @i EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'id' EXEC sp_OAMethod @json, 'StringOf', @username OUT, 'username' EXEC sp_OAMethod @json, 'StringOf', @active OUT, 'active' EXEC sp_OAMethod @json, 'StringOf', @description OUT, 'description' EXEC sp_OAMethod @json, 'StringOf', @from_account OUT, 'from_account' EXEC sp_OAMethod @json, 'StringOf', @per_month OUT, 'per_month' EXEC @hr = sp_OADestroy @json SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jarrResp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.