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) ETrade v1 List AccountsList ETrade accounts using the ETrade v1 API.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Handle hoJson Boolean iSuccess String sRespStr Integer iStatusCode Handle hoXml Integer i Integer iCount_i String sTagPath Integer iAccountId String sAccountIdKey String sAccountMode String sAccountDesc String sAccountName String sAccountType String sInstitutionType String sAccountStatus Integer iClosedDate String sTemp1 Boolean bTemp1 // This example requires 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 Set ComOAuth1 Of hoHttp To True Set ComOAuthVerifier Of hoHttp To "" Set ComOAuthConsumerKey Of hoHttp To "ETRADE_CONSUMER_KEY" Set ComOAuthConsumerSecret Of hoHttp To "ETRADE_CONSUMER_SECRET" // Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2. Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoadFile Of hoJson "qa_data/tokens/etrade.json" To iSuccess If (iSuccess <> True) Begin Showln "Failed to load OAuth1 token" Procedure_Return End Get ComStringOf Of hoJson "oauth_token" To sTemp1 Set ComOAuthToken Of hoHttp To sTemp1 Get ComStringOf Of hoJson "oauth_token_secret" To sTemp1 Set ComOAuthTokenSecret Of hoHttp To sTemp1 // See the ETrade v1 API documentation HERE. Get ComQuickGetStr Of hoHttp "https://apisb.etrade.com/v1/accounts/list" To sRespStr Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // A 200 status code indicates success. Get ComLastStatus Of hoHttp To iStatusCode Showln "statusCode = " iStatusCode // Use the following online tool to generate parsing code from sample XML: // Generate Parsing Code from XML // A sample XML response is shown below... Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Get ComLoadXml Of hoXml sRespStr To iSuccess Move 0 To i Get ComNumChildrenHavingTag Of hoXml "Accounts|Account" To iCount_i While (i < iCount_i) Set ComI Of hoXml To i Get ComGetChildIntValue Of hoXml "Accounts|Account[i]|accountId" To iAccountId Get ComGetChildContent Of hoXml "Accounts|Account[i]|accountIdKey" To sAccountIdKey Get ComGetChildContent Of hoXml "Accounts|Account[i]|accountMode" To sAccountMode Get ComGetChildContent Of hoXml "Accounts|Account[i]|accountDesc" To sAccountDesc Get ComGetChildContent Of hoXml "Accounts|Account[i]|accountName" To sAccountName Get ComGetChildContent Of hoXml "Accounts|Account[i]|accountType" To sAccountType Get ComGetChildContent Of hoXml "Accounts|Account[i]|institutionType" To sInstitutionType Get ComGetChildContent Of hoXml "Accounts|Account[i]|accountStatus" To sAccountStatus Get ComGetChildIntValue Of hoXml "Accounts|Account[i]|closedDate" To iClosedDate Move (i + 1) To i Loop // <?xml version="1.0" encoding="UTF-8"?> // <AccountListResponse> // <Accounts> // <Account> // <accountId>84010429</accountId> // <accountIdKey>JIdOIAcSpwR1Jva7RQBraQ</accountIdKey> // <accountMode>MARGIN</accountMode> // <accountDesc>INDIVIDUAL</accountDesc> // <accountName>Individual Brokerage</accountName> // <accountType>INDIVIDUAL</accountType> // <institutionType>BROKERAGE</institutionType> // <accountStatus>ACTIVE</accountStatus> // <closedDate>0</closedDate> // </Account> // <Account> // <accountId>84010430</accountId> // <accountIdKey>JAAOIAcSpwR1Jva7RQBraQ</accountIdKey> // <accountMode>MARGIN</accountMode> // <accountDesc>INDIVIDUAL</accountDesc> // <accountName>Individual Brokerage</accountName> // <accountType>INDIVIDUAL</accountType> // <institutionType>BROKERAGE</institutionType> // <accountStatus>ACTIVE</accountStatus> // <closedDate>0</closedDate> // </Account> // </Accounts> // </AccountListResponse> End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.