问题
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>
回答1:
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.
回答2:
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
回答3:
Have you tried surrounding the span id attributes with quotes?
来源:https://stackoverflow.com/questions/2192918/problem-with-stock-quote-from-google-finance