Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(DataFlex) ETrade v1 List Accounts

List ETrade accounts using the ETrade v1 API.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-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-2019 Chilkat Software, Inc. All Rights Reserved.