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
(SQL Server) ETrade Get QuoteShows how to send a GET for a stock quote using ETrade with OAuth1 authorization.
// Important: See this note about string length limitations for strings returned by sp_OAMethod calls. // CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat HTTP API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OASetProperty @http, 'OAuth1', 1 EXEC sp_OASetProperty @http, 'OAuthVerifier', '' EXEC sp_OASetProperty @http, 'OAuthConsumerKey', 'ETRADE_CONSUMER_KEY' EXEC sp_OASetProperty @http, 'OAuthConsumerSecret', 'ETRADE_CONSUMER_SECRET' -- Load the access token previously obtained via the OAuth1 3-Legged Authorization DECLARE @json int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT DECLARE @success int EXEC sp_OAMethod @json, 'LoadFile', @success OUT, 'qa_data/tokens/etrade.json' IF @success <> 1 BEGIN PRINT 'Failed to load OAuth1 token' EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json RETURN END EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'oauth_token' EXEC sp_OASetProperty @http, 'OAuthToken', @sTmp0 EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'oauth_token_secret' EXEC sp_OASetProperty @http, 'OAuthTokenSecret', @sTmp0 DECLARE @respStr nvarchar(4000) EXEC sp_OAMethod @http, 'QuickGetStr', @respStr OUT, 'https://etwssandbox.etrade.com/market/sandbox/rest/quote/MSFT?detailFlag=ALL' EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json RETURN END -- The response is XML. A sample response is shown below. PRINT @respStr PRINT 'success.' -- Sample XML response: -- <QuoteResponse> -- <QuoteData> -- <all> -- <adjNonAdjFlag>false</adjNonAdjFlag> -- <annualDividend>0.52</annualDividend> -- <ask>28.71</ask> -- <askExchange>NASDAQ National Market Sys (NMS)</askExchange> -- <askSize>15600</askSize> -- <askTime>12:14:22 EST 02-24-2010</askTime> -- <bid>28.7</bid> -- <bidExchange></bidExchange> -- <bidSize>15600</bidSize> -- <bidTime>12:14:22 EST 02-24-2010</bidTime> -- <chgClose>-0.3400000000000001</chgClose> -- <chgClosePrcn>-15.11</chgClosePrcn> -- <companyName>MICROSOFT CORP</companyName> -- <daysToExpiration>0</daysToExpiration> -- <dirLast>U</dirLast> -- <dividend>0.13</dividend> -- <eps>1.81</eps> -- <estEarnings>1.811</estEarnings> -- <exDivDate>11/17/2009</exDivDate> -- <exchgLastTrade>Pacific</exchgLastTrade> -- <fsi>N</fsi> -- <high>28.77</high> -- <high52>31.5</high52> -- <highAsk>28.77</highAsk> -- <highBid>28.76</highBid> -- <lastTrade>28.705</lastTrade> -- <low>28.38</low> -- <low52>14.87</low52> -- <lowAsk>28.39</lowAsk> -- <lowBid>28.0</lowBid> -- <numTrades>61376</numTrades> -- <open>28.52</open> -- <openInterest>0</openInterest> -- <optionStyle></optionStyle> -- <optionUnderlier></optionUnderlier> -- <prevClose>28.73</prevClose> -- <prevDayVolume>75648887</prevDayVolume> -- <primaryExchange>Q</primaryExchange> -- <symbolDesc>MICROSOFT CORP</symbolDesc> -- <todayClose>0.0</todayClose> -- <totalVolume>22403011</totalVolume> -- <upc>0</upc> -- <volume10Day>56676460</volume10Day> -- </all> -- <dateTime>12:14:22 EST 02-24-2010</dateTime> -- <product> -- <symbol>MSFT</symbol> -- <type>EQ</type> -- <exchange>Q</exchange> -- </product> -- </QuoteData> -- </QuoteResponse> EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.