views:

557

answers:

4

Hi All,

Below is the example I got from google finance for a stock quote. But it doesnt seem to be working. Stock price isnt displayed.

Thanks

<body>
Hello world!
Here is your portfolio:<br/>
  GOOG: <span id=_IG_SYM1_l></span> (<span id=_IG_SYM1_c></span>)<br/>
  AAPL: <span id=_IG_SYM2_l></span> (<span id=_IG_SYM2_c></span>)<br/>
  INTC: <span id=_IG_SYM3_l></span> (<span id=_IG_SYM3_c></span>)<br/>


<script type="text/javascript">
  var quote = new google.finance.Quote();
  quote.enableDomUpdates( { 'GOOG' : '_IG_SYM1', 'AAPL' : '_IG_SYM2', 
    'INTC' : '_IG_SYM3' } );

  quote.getQuotes(["GOOG", "AAPL", "INTC"]);
</script>


<!-- start: javascripts -->

<!-- end: javascripts -->
</body>
A: 

You probably need Authenticating to the Google Finance service first.

The AuthSubRequest URL might look like this:

https://www.google.com/accounts/AuthSubRequest?
scope=http%3A%2F%2Ffinance.google.com%2Ffinance%2Ffeeds%2F&session=1&secure=0
&next=http%3A%2F%2Fwww.example.com%2Fwelcome.

http://code.google.com/apis/finance/docs/2.0/developers_guide_protocol.html#Authenticating

Yada
Thanks Yada ... went thru the link do i need to add it before calling any API?
kjkjl
This authentication is for a different API, which does not provide access to raw stock quotes.
Matthew Flaschen
can anyone please help me how the code should look like?
kjkjl
A: 

Have you tried surrounding the span id attributes with quotes?

Peter
A: 

It looks like you are using the example at http://code.google.com/apis/finance/docs/finance-gadgets.html#JS_API . If I understand right, that API is only available to gadgets. It says,

"Gadgets that use the Market Data API can only run in iGoogle--either production iGoogle, or the iGoogle sandbox."

The regular Google Finance JS API only allows you to get data associated with a user's portfolio.

Matthew Flaschen
can anyone please help me how the code should look like?
kjkjl
That's the thing. I don't think there /is/ an API to get raw Google stock quotes on an arbitrary web page.
Matthew Flaschen
ok thanks ......
kjkjl
A: 

What is it you are trying to do? Depending on what you want to achieve, there may be a better way of doing it.