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
(Unicode C) qa.factura1.com.co Obtain Auth TokenDemonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; HCkJsonObjectW json; HCkHttpResponseW resp; HCkJsonObjectW jsonResp; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); // Build the following JSON // { // "password": "MY_PASSWORD", // "username": "MY_USERNAME" // } json = CkJsonObjectW_Create(); CkJsonObjectW_putEmitCompact(json,FALSE); CkJsonObjectW_UpdateString(json,L"password",L"MY_PASSWORD"); CkJsonObjectW_UpdateString(json,L"username",L"MY_USERNAME"); resp = CkHttpW_PostJson3(http,L"https://qa.factura1.com.co/v2/auth",L"application/json",json); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); return; } jsonResp = CkJsonObjectW_Create(); CkJsonObjectW_putEmitCompact(jsonResp,FALSE); CkJsonObjectW_Load(jsonResp,CkHttpResponseW_bodyStr(resp)); CkHttpResponseW_Dispose(resp); wprintf(L"%s\n",CkJsonObjectW_emit(jsonResp)); wprintf(L"Access token: %s\n",CkJsonObjectW_stringOf(jsonResp,L"token")); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); CkJsonObjectW_Dispose(jsonResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.