5 Minute Developer: How to Build a Real-Time Stock Quote Widget in 5 Minutes
First Published Tuesday, 9th March 2010 03:06 pm from Xand : ChasCooper
The opinions expressed by this blogger and those providing comments are theirs alone, this does not reflect the opinion of Automated Trader or any employee thereof. Automated Trader is not responsible for the accuracy of any of the information supplied by this article.
/>
src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F03%2F5-minute-developer-how-to-build-a-real-time-stock-quote-widget-in-5-minutes%2F&source=xignite&style=normal"
height="61" width="51" />
In the next 5 minutes, you could get $5 worth of
plumbing services, $30 worth of legal advice or $17 worth of
psychotherapy. Or, you could just spend your next five minutes
building a href="http://www.xignite.com/stock-quote/web-service/2000306.html">real-time
stock quote widget. Don't think it can be done in 5
minutes? Check out a href="http://www.xignite.com/stock-quote/web-service/2000306.html">video
showing us doing it in less time.
Here's how you can do the same thing using PHP and
Eclipse, although the same basic process can be used for any
language and any IDE:
Step
1: href="http://www.xignite.com/stock-quote/real-time-stock-quotes-data--20003003.html">Subscribe
to XigniteRealTime to get access to real-time, Level I
stock quotes. If you're not ready to subscribe yet, you can also
href="https://www.xignite.com/MyAccount/Register.aspx">sign up
for a free trial and get access to other real-time
stock quote web services such as href="http://www.xignite.com/xNASDAQLastSale.asmx">XigniteNASDAQLastSale
and href="http://www.xignite.com/xBATSLastSale.asmx">XigniteBATSLastSale.
You'll need to make a few adjustments to the sample code below to
point to a different web service, but nothing major.
Step 2: Start a new PHP
project in Eclipse.
Step
3: Create your index.php page with the following
code:
<html><title>Get
Real-Time
Quote</title><body><form>
<input
type="text"
name="symbol"
/>
<input
type="submit"
value="Go"
/>
</form></body></html>
<?php
$client =
new
SoapClient('http://www.xignite.com/xRealTime.asmx?WSDL');
$quote =
$client->GetRealQuote(array('Exchange'
=> "INET",
'Symbol' =>
$_GET["Symbol"],
'IncludeBidAsk'
=>
"false"));
echo
"Last price: ",
$quote->GetRealQuoteResult->Last;
?>
Step 4: Open a browser and
load your index.php page to give your new stock quote widget a
spin.
Congratulations! You just
built a real-time stock quote widget in PHP and made a plumber, a
lawyer and a psychotherapist very disappointed in you for such a
ridiculous waste of your time.
Share and Enjoy: rel="nofollow" target="_blank"
href="mailto:?subject=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Real-Time%20Stock%20Quote%20Widget%20in%205%20Minutes&body=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F03%2F5-minute-developer-how-to-build-a-real-time-stock-quote-widget-in-5-minutes%2F"
title="email">
src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/email_link.png"
title="email" alt="email" class="sociable-hovers" />
title="Twitter" alt="Twitter" class="sociable-hovers"
title="Facebook" alt="Facebook" class="sociable-hovers"
title="LinkedIn" alt="LinkedIn" class="sociable-hovers"
title="Digg">
src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/digg.png"
title="Digg" alt="Digg" class="sociable-hovers" />
title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers"
title="Technorati" alt="Technorati" class="sociable-hovers"
title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme
via Twitter" class="sociable-hovers" /> rel="nofollow" target="_blank"
href="http://delicious.com/post?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F03%2F5-minute-developer-how-to-build-a-real-time-stock-quote-widget-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Real-Time%20Stock%20Quote%20Widget%20in%205%20Minutes¬es=In%205%20minutes%2C%20you%20can%20create%20a%20real-time%20stock%20quote%20widget%20with%20Level%20I%20stock%20market%20data%20using%20Xignite%20web%20services.%20%20Although%20you%20can%20do%20this%20in%20any%20language%20or%20IDE%2C%20this%20example%20uses%20PHP%20and%20Eclipse."
title="del.icio.us">
src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/delicious.png"
title="del.icio.us" alt="del.icio.us" class="sociable-hovers"
title="Google Bookmarks" alt="Google Bookmarks"
title="Live">
src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/live.png"
title="Live" alt="Live" class="sociable-hovers" />




