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) ETrade v1 List TransactionsGet information about the transactions in an ETrade brokerage account.
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> #include <C_CkXmlW.h> void ChilkatSample(void) { HCkHttpW http; HCkJsonObjectW json; BOOL success; const wchar_t *respStr; int statusCode; HCkXmlW xml; int i; int count_i; const wchar_t *tagPath; const wchar_t *transactionId; int accountId; const wchar_t *transactionDate; const wchar_t *postDate; int amount; const wchar_t *description; int description2; const wchar_t *transactionType; const wchar_t *imageFlag; const wchar_t *instType; int quantity; int price; const wchar_t *settlementCurrency; const wchar_t *paymentCurrency; int fee; const wchar_t *settlementDate; const wchar_t *detailsURI; const wchar_t *pageMarkers; const wchar_t *moreTransactions; int transactionCount; int totalCount; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); CkHttpW_putOAuth1(http,TRUE); CkHttpW_putOAuthVerifier(http,L""); CkHttpW_putOAuthConsumerKey(http,L"ETRADE_CONSUMER_KEY"); CkHttpW_putOAuthConsumerSecret(http,L"ETRADE_CONSUMER_SECRET"); // Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2. json = CkJsonObjectW_Create(); success = CkJsonObjectW_LoadFile(json,L"qa_data/tokens/etrade.json"); if (success != TRUE) { wprintf(L"Failed to load OAuth1 token\n"); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); return; } CkHttpW_putOAuthToken(http,CkJsonObjectW_stringOf(json,L"oauth_token")); CkHttpW_putOAuthTokenSecret(http,CkJsonObjectW_stringOf(json,L"oauth_token_secret")); // See the ETrade v1 API documentation HERE. CkHttpW_SetUrlVar(http,L"accountIdKey",L"vsnhtF7d9jXxBy6HyaAC4vQ"); respStr = CkHttpW_quickGetStr(http,L"https://apisb.etrade.com/v1/accounts/{$accountIdKey}/transactions"); if (CkHttpW_getLastMethodSuccess(http) != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); return; } // A 200 status code indicates success. statusCode = CkHttpW_getLastStatus(http); wprintf(L"statusCode = %d\n",statusCode); // Use the following online tool to generate parsing code from sample XML: // Generate Parsing Code from XML // A sample XML response is shown below... xml = CkXmlW_Create(); CkXmlW_LoadXml(xml,respStr); i = 0; count_i = CkXmlW_NumChildrenHavingTag(xml,L"Transaction"); while (i < count_i) { CkXmlW_putI(xml,i); transactionId = CkXmlW_getChildContent(xml,L"Transaction[i]|transactionId"); accountId = CkXmlW_GetChildIntValue(xml,L"Transaction[i]|accountId"); transactionDate = CkXmlW_getChildContent(xml,L"Transaction[i]|transactionDate"); postDate = CkXmlW_getChildContent(xml,L"Transaction[i]|postDate"); amount = CkXmlW_GetChildIntValue(xml,L"Transaction[i]|amount"); description = CkXmlW_getChildContent(xml,L"Transaction[i]|description"); description2 = CkXmlW_GetChildIntValue(xml,L"Transaction[i]|description2"); transactionType = CkXmlW_getChildContent(xml,L"Transaction[i]|transactionType"); imageFlag = CkXmlW_getChildContent(xml,L"Transaction[i]|imageFlag"); instType = CkXmlW_getChildContent(xml,L"Transaction[i]|instType"); quantity = CkXmlW_GetChildIntValue(xml,L"Transaction[i]|brokerage|quantity"); price = CkXmlW_GetChildIntValue(xml,L"Transaction[i]|brokerage|price"); settlementCurrency = CkXmlW_getChildContent(xml,L"Transaction[i]|brokerage|settlementCurrency"); paymentCurrency = CkXmlW_getChildContent(xml,L"Transaction[i]|brokerage|paymentCurrency"); fee = CkXmlW_GetChildIntValue(xml,L"Transaction[i]|brokerage|fee"); settlementDate = CkXmlW_getChildContent(xml,L"Transaction[i]|brokerage|settlementDate"); detailsURI = CkXmlW_getChildContent(xml,L"Transaction[i]|detailsURI"); i = i + 1; } pageMarkers = CkXmlW_getChildContent(xml,L"pageMarkers"); moreTransactions = CkXmlW_getChildContent(xml,L"moreTransactions"); transactionCount = CkXmlW_GetChildIntValue(xml,L"transactionCount"); totalCount = CkXmlW_GetChildIntValue(xml,L"totalCount"); // <?xml version="1.0" encoding="UTF-8"?> // <TransactionListResponse> // <Transaction> // <transactionId>18165100001766</transactionId> // <accountId>83564979</accountId> // <transactionDate>1528948800000</transactionDate> // <postDate>1528948800000</postDate> // <amount>-2</amount> // <description>ACH WITHDRAWL REFID:109187276;</description> // <description2>109187276</description2> // <transactionType>Transfer</transactionType> // <memo /> // <imageFlag>false</imageFlag> // <instType>BROKERAGE</instType> // <brokerage> // <product /> // <quantity>0</quantity> // <price>0</price> // <settlementCurrency>USD</settlementCurrency> // <paymentCurrency>USD</paymentCurrency> // <fee>0</fee> // <settlementDate>1528948800000</settlementDate> // </brokerage> // <detailsURI>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/transactions/18165100001766</detailsURI> // </Transaction> // <Transaction> // <transactionId>18158100000983</transactionId> // <accountId>83564979</accountId> // <transactionDate>1528344000000</transactionDate> // <postDate>1528344000000</postDate> // <amount>-2</amount> // <description>ACH WITHDRAWL REFID:98655276;</description> // <description2>98655276</description2> // <transactionType>Transfer</transactionType> // <memo /> // <imageFlag>false</imageFlag> // <instType>BROKERAGE</instType> // <brokerage> // <product /> // <quantity>0</quantity> // <price>0</price> // <settlementCurrency>USD</settlementCurrency> // <paymentCurrency>USD</paymentCurrency> // <fee>0</fee> // <settlementDate>1528344000000</settlementDate> // </brokerage> // <detailsURI>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/transactions/18158100000983</detailsURI> // </Transaction> // <pageMarkers>eNpTsAlITE91zi%2FNK%2FHMc04syi8tTs2xM7TRxybMpWATkl%2BSmBOUmpxflAKWtTO10ccQg6mDmwEyEE0EqAbE8SvNTUotCk4tLE3NS061M9Ax0DEEYgOIA9BkuRQgmjxTfDKLQUYoQAV8E4uyU4vsDC0MzUwNDYDA0NzMrKamBmIKVJYLphpiKsyTUB7IbH1kwwFa7F0D</pageMarkers> // <moreTransactions>false</moreTransactions> // <transactionCount>5</transactionCount> // <totalCount>5</totalCount> // </TransactionListResponse CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); CkXmlW_Dispose(xml); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.