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) Bitfinex v2 REST User InfoRetrieve the user ID, email, username and timezone setting for the account associated with the API key used. For more information, see https://docs.bitfinex.com/reference#rest-auth-info-user
#include <C_CkHttpW.h> #include <C_CkCrypt2W.h> #include <C_CkDateTimeW.h> #include <C_CkStringBuilderW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkCrypt2W crypt; const wchar_t *apiPath; const wchar_t *apiKey; const wchar_t *apiSecret; HCkDateTimeW dt; HCkStringBuilderW sbNonce; const wchar_t *nonce; const wchar_t *body; HCkStringBuilderW sbSignature; const wchar_t *sig; HCkHttpResponseW resp; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); // Implements the following CURL command: // curl -X POST -H "bfx-nonce: nonce" \ // -H "bfx-apikey: apiKey" \ // -H "bfx-signature: sig" \ // https://api.bitfinex.com/v2/auth/r/info/user // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code crypt = CkCrypt2W_Create(); apiPath = L"v2/auth/r/info/user"; apiKey = L"MY_API_KEY"; apiSecret = L"MY_API_SECRET"; dt = CkDateTimeW_Create(); CkDateTimeW_SetFromCurrentSystemTime(dt); sbNonce = CkStringBuilderW_Create(); CkStringBuilderW_Append(sbNonce,CkDateTimeW_getAsUnixTimeStr(dt,FALSE)); CkStringBuilderW_Append(sbNonce,L"000"); nonce = CkStringBuilderW_getAsString(sbNonce); // This particular request has an empty body. body = L""; sbSignature = CkStringBuilderW_Create(); CkStringBuilderW_Append(sbSignature,L"/api/"); CkStringBuilderW_Append(sbSignature,apiPath); CkStringBuilderW_Append(sbSignature,nonce); CkStringBuilderW_Append(sbSignature,body); CkCrypt2W_putEncodingMode(crypt,L"hex_lower"); CkCrypt2W_putHashAlgorithm(crypt,L"sha384"); CkCrypt2W_putMacAlgorithm(crypt,L"hmac"); CkCrypt2W_SetMacKeyString(crypt,apiSecret); sig = CkCrypt2W_macStringENC(crypt,CkStringBuilderW_getAsString(sbSignature)); CkHttpW_SetRequestHeader(http,L"bfx-apikey",apiKey); CkHttpW_SetRequestHeader(http,L"bfx-signature",sig); CkHttpW_SetRequestHeader(http,L"bfx-nonce",nonce); resp = CkHttpW_QuickRequest(http,L"POST",L"https://api.bitfinex.com/v2/auth/r/info/user"); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkCrypt2W_Dispose(crypt); CkDateTimeW_Dispose(dt); CkStringBuilderW_Dispose(sbNonce); CkStringBuilderW_Dispose(sbSignature); return; } wprintf(L"Response body:\n"); wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp)); // Sample response body: // [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"] CkHttpW_Dispose(http); CkCrypt2W_Dispose(crypt); CkDateTimeW_Dispose(dt); CkStringBuilderW_Dispose(sbNonce); CkStringBuilderW_Dispose(sbSignature); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.