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
(Delphi DLL) 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
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, BinData, Http; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; success: Boolean; bdResponseBody: HCkBinData; respStatusCode: Integer; begin // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := CkHttp_Create(); // 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. CkHttp_putAuthToken(http,'your-auth-token'); bdResponseBody := CkBinData_Create(); success := CkHttp_QuickGetBd(http,'https://your-webapp-hostname:your-webapp-port/v1/media/4b5bf27b-8672-4d55-bc21-d096dc200d0f',bdResponseBody); if (success = False) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; respStatusCode := CkHttp_getLastStatus(http); Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode)); Memo1.Lines.Add('response header = ' + CkHttp__lastResponseHeader(http)); if (respStatusCode <> 200) then begin Memo1.Lines.Add('Error response body:'); Memo1.Lines.Add(CkBinData__getString(bdResponseBody,'utf-8')); Exit; end; success := CkBinData_WriteFile(bdResponseBody,'path/filename'); CkHttp_Dispose(http); CkBinData_Dispose(bdResponseBody); end; |
© 2000-2023 Chilkat Software, Inc. All Rights Reserved.