|  | 
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
| (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 Note: This example requires Chilkat v11.0.0 or greater. 
 #include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { BOOL success; HCkHttpW http; HCkJsonObjectW json; HCkHttpResponseW resp; HCkJsonObjectW jsonResp; success = FALSE; // 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 = CkHttpResponseW_Create(); success = CkHttpW_HttpJson(http,L"POST",L"https://qa.factura1.com.co/v2/auth",json,L"application/json",resp); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); CkHttpResponseW_Dispose(resp); return; } jsonResp = CkJsonObjectW_Create(); CkJsonObjectW_putEmitCompact(jsonResp,FALSE); CkJsonObjectW_Load(jsonResp,CkHttpResponseW_bodyStr(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); CkHttpResponseW_Dispose(resp); CkJsonObjectW_Dispose(jsonResp); } | ||||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.