雅虎货币转换器 API

Yahoo Currency Converter API

我一直在使用雅虎货币转换器,没有出现任何问题。

这里是Java中的函数代码:

 public static Float convert(String currencyFrom, String currencyTo) throws IOException {
    HttpClient httpclient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet("http://quote.yahoo.com/d/quotes.csv?s=" + currencyFrom + currencyTo + "=X&f=l1&e=.csv");
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String responseBody = httpclient.execute(httpGet, responseHandler);
    httpclient.getConnectionManager().shutdown();
    return Float.parseFloat(responseBody);

 }

然而,就在昨天我意识到它抛出以下错误:

It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com.

我使用的代码有问题吗?或者服务是否已永久停止。对于实时货币换算还有其他建议吗?

我可以确认该服务已于夜间停止。

https://forums.yahoo.net/t5/Yahoo-Finance-help/http-download-finance-yahoo-com-d-quotes-csv-s-GOOG-amp-f/m-p/387662/highlight/true#M6207

这是社区网站管理员的回答。

虽然已停产,但您可以查看替代方案,例如 http://fixer.io,它允许您通过 JSON

执行类似的操作

https://api.fixer.io/latest?base=currencyFrom&symbols=currencyTo