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
(DataFlex) WaTrend Send WhatsApp TextSee more WaTrend ExamplesSend a WhatsApp text.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vReq Handle hoReq Handle hoSbUrl String sResponseBodyStr Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Integer iRespStatusCode Handle hoJResp String sStatus String sTemp1 Boolean bTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Use your actual access token instead of 555555555555555555555555555555 Get Create (RefClass(cComChilkatHttpRequest)) To hoReq If (Not(IsComObjectCreated(hoReq))) Begin Send CreateComObject of hoReq End Send ComAddParam To hoReq "number" "84933313xxx" Send ComAddParam To hoReq "type" "text" Send ComAddParam To hoReq "message" "This is a test message" Send ComAddParam To hoReq "instance_id" "609ACF283XXXX" Send ComAddParam To hoReq "access_token" "555555555555555555555555555555" // Note: The WaTrend online documentation indicate a POST should be used. // However, it seems you might actually need to send a GET request. // It is unclear. // If a GET is neeed, you would just send to the URL w/ query params like this: Get Create (RefClass(cComChilkatStringBuilder)) To hoSbUrl If (Not(IsComObjectCreated(hoSbUrl))) Begin Send CreateComObject of hoSbUrl End Get ComAppend Of hoSbUrl "https://app.watrend.com/api/send.php?" To iSuccess Get ComGetUrlEncodedParams Of hoReq To sTemp1 Get ComAppend Of hoSbUrl sTemp1 To iSuccess Get ComGetAsString Of hoSbUrl To sTemp1 Get ComQuickGetStr Of hoHttp sTemp1 To sResponseBodyStr // The responseBodyStr contains the JSON response from the server.. // If a POST is needed, then it is sent like this: Get pvComObject of hoReq to vReq Get ComPostUrlEncoded Of hoHttp "https://app.watrend.com/api/send.php" vReq To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess Get ComStatusCode Of hoResp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComHeader Of hoResp To sTemp1 Showln sTemp1 Showln "Failed." Send Destroy of hoResp Procedure_Return End Get ComBodyStr Of hoResp To sTemp1 Showln sTemp1 // Both success and failed responses use 200 status code. // A success response contains this JSON in the response body: // {"status":"success", ... } // A failed response will contain something like this: // {"status":"error","message":"License Invalidated"} Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Get ComStringOf Of hoJResp "status" To sStatus Showln "status: " sStatus Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.