PHP 中的雅虎财经 CSV API 和 appid
我有一个小应用程序从 Yahoo! 检索股票数据在我的本地服务器上工作正常。当我将其上传到远程服务器时,它停止返回数据并在 FF 中显示安全错误:“此网站不提供所有权信息。”
然后我意识到我必须申请一个应用程序 ID,但问题仍然存在:
$appid = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx--'); // My App ID
...
$cHandle = curl_init();
curl_setopt($cHandle, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?appid='.$appid.'&s='.$symbol.'&f='.$properties.'&e=.csv');
curl_setopt($cHandle, CURLOPT_RETURNTRANSFER, true);
$dataStr = curl_exec($cHandle);
curl_close($cHandle);
echo json_encode($dataStr);
知道我的代码出了什么问题吗?提前致谢
I've a small application retrieving stock data from Yahoo! working fine in my local server. When I uploaded it to a remote server it stopped returning data and showing a security error in FF: "This web site does not supply ownership information."
Then I realized I must apply for an application ID wich I did but still the problem remains:
$appid = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx--'); // My App ID
...
$cHandle = curl_init();
curl_setopt($cHandle, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?appid='.$appid.'&s='.$symbol.'&f='.$properties.'&e=.csv');
curl_setopt($cHandle, CURLOPT_RETURNTRANSFER, true);
$dataStr = curl_exec($cHandle);
curl_close($cHandle);
echo json_encode($dataStr);
Any idea what's wrong in my code? Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的错误与您的代码无关 - Firefox 中的错误与 SSL 证书有关。至于为什么你的代码不起作用 - 在 CURL 周围添加一些错误检查,看看会产生什么:
Your error is not connected with your code - the Error in Firefox is related to the SSL certificate. As to why your code is not working - add some error checking around the CURL and see what that produces :