In this chapter, you’ll be introduced to the
Web component through a relatively
simple example that accesses fnancial stock price information from a public API
made available by Yahoo Finance. The protocol for talking to this API is fairly simple,
and the data returned is in a list of values separated by commas (comma-separated
values , or CSV), so it serves as a nice introduction to API communication.
Unfortunately, most APIs have complicated permission schemes and APIs, and they
require some advanced code to parse.
STOCK MARKET SAMPLE
The figure below shows the blocks for an app that displays Google stock information when
the app launches.
Screen.Initialize, Web1.Url is set to the URL for communicating with Yahoo
Web1.Get is called, the request is made, but no data is returned
Instead, when Yahoo returns the requested data to your app, the
event is triggered, and this is where you can process the returned data. The event
responseContent holds the data. As just mentioned, the Yahoo Finance API
returns data in CSV format. If you build this app and run it, you’ll see that the current Google stock price and the change in the price for the day are displayed in
StockInfoLabel , separated by commas.
You can customize the
Web.Url to get the information for a diferent company (or
companies), and to get various types of stock market information. The Yahoo Finance
API, at https://code.google.com/p/yahoo-fnance-managed/wiki/CSVAPI , specifes how
you can change the URL to customize your request, as well as the format of the data it
NOTE: I HAVE COPIED THIS FROM THIS WEBSITE . I DO NOT OWN THIS.