![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) WhatsApp - Download/Retrieve MediaDemonstrates how to download media previously uploaded to the WhatsApp Business API client For more information, see https://developers.facebook.com/docs/whatsapp/api/media#retrieve
-- 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 -X GET \ -- https://your-webapp-hostname:your-webapp-port/v1/media/4b5bf27b-8672-4d55-bc21-d096dc200d0f \ -- -H 'Authorization: Bearer your-auth-token' \ -- -o path/filename -- 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 your-auth-token" header. EXEC sp_OASetProperty @http, 'AuthToken', 'your-auth-token' DECLARE @bdResponseBody int -- Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.BinData', @bdResponseBody OUT EXEC sp_OAMethod @http, 'QuickGetBd', @success OUT, 'https://your-webapp-hostname:your-webapp-port/v1/media/4b5bf27b-8672-4d55-bc21-d096dc200d0f', @bdResponseBody IF @success = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @bdResponseBody RETURN END DECLARE @respStatusCode int EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT PRINT 'response status code = ' + @respStatusCode EXEC sp_OAGetProperty @http, 'LastResponseHeader', @sTmp0 OUT PRINT 'response header = ' + @sTmp0 IF @respStatusCode <> 200 BEGIN PRINT 'Error response body:' EXEC sp_OAMethod @bdResponseBody, 'GetString', @sTmp0 OUT, 'utf-8' PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @bdResponseBody RETURN END EXEC sp_OAMethod @bdResponseBody, 'WriteFile', @success OUT, 'path/filename' EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @bdResponseBody END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.