Problem with Stock Quote from Google Finance

巧了我就是萌 提交于 2019-12-12 01:36:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!