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
(DataFlex) WhatsApp - LoginLog in to get your authentication token (which is to be used in the "Authorization: Bearer your-auth-token" header in other REST API calls). For more information, see https://developers.facebook.com/docs/whatsapp/api/users/login
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vJson Handle hoJson Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode String sToken String sExpires_after Integer i Integer iCount_i 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 // Implements the following CURL command: // curl -X POST https://your-webapp-hostname:your-webapp-port/v1/users/login \ // -H 'Content-Type: application/json' \ // --user 'username:password' \ // -d '{}' Set ComLogin Of hoHttp To "username" Set ComPassword Of hoHttp To "password" // The following JSON is sent in the request body. // {} Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Send ComSetRequestHeader To hoHttp "Content-Type" "application/json" Get pvComObject of hoJson to vJson Get ComPostJson3 Of hoHttp "https://your-webapp-hostname:your-webapp-port/v1/users/login" "application/json" vJson 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 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 Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp To sTemp1 Showln sTemp1 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 Send Destroy of hoResp // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "users": [ // { // "token": "eyJhbGciOHlXVCJ9.eyJ1c2VyIjoNTIzMDE2Nn0.mEoF0COaO00Z1cANo", // "expires_after": "2018-03-01 15:29:26+00:00" // } // ] // } // Sample code for parsing the JSON response... Move 0 To i Get ComSizeOfArray Of hoJResp "users" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "users[i].token" To sToken Get ComStringOf Of hoJResp "users[i].expires_after" To sExpires_after Move (i + 1) To i Loop End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.