We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(8)
free.currencyconverterapi.com 返回 JSON 格式的结果。
Web 服务还支持 JSONP。该 API 非常易于使用,它可以让您将一种货币转换为另一种货币。
免责声明,我是该网站的作者。
示例转换 URL 为: http://free.currencyconverterapi.com/api/v6/convert?q=USD_PHP&compact=ultra&apiKey=sample-api-key 它将返回 json 格式的值,例如 {"USD_PHP": 51.459999}
free.currencyconverterapi.com returns results in JSON format.
The web service also supports JSONP. The API is very easy to use, and it lets you convert one currency to another.
Disclaimer, I'm the author of the website.
A sample conversion URL is: http://free.currencyconverterapi.com/api/v6/convert?q=USD_PHP&compact=ultra&apiKey=sample-api-key which will return a value in json format, e.g. {"USD_PHP":51.459999}
正如评论中提到的,该服务已于 2013 年 11 月关闭。
Google 计算器 API 可以执行此操作;请求:
响应:
(更多信息)
As mentioned in the comments this service was shut down in Nov 2013.
Googles calulator API can do this;Request:
Response:
(More info)
雅虎不再工作。请参阅下面的评论
雅虎财经货币转换器。< Strike>此网址格式可用于获取不同格式的转化率。
用适当的格式和参数替换quotes.csv以及所需的代码
编辑:添加示例网址格式
Yahoo is no longer working. See comment below
Yahoo Finance Currency Converter.This url format could be used to fetch conversion rates in different formats.Substitute quotes.csv with appropriate format and parameters with the required codes
EDIT: Added Example Url formats
现在 iGoogle 已经被淘汰了,Alex K 的解决方案不再有效。
在 php 中,这是一种替代方案,其工作方式相同并且同样有效:
Now iGoogle has been killed off, Alex K's solution no longer works sadly.
In php, this is an alternative which works in the same way and is just as effective:
更新:Yahoo API 不再工作。留下这个旧答案只是为了提供这不再工作的信息。
使用yahoo api:
它将返回json格式,例如:
在URL中查看现在有USDLTL,所以只需更改为您需要的即可。
另外,有时汇率非常低,即使显示 4 个数字,您也看不到它:
汇率:0.0006
不要惊慌,只需进行反转查询、翻转货币并进行一些简单的数学计算即可。
例如,您得到的汇率是从韩元到欧元 0.0006,但实际汇率类似于 0.00000125,所以再次询问 API,只需翻转货币:欧元到美元的比率是多少。那么你会得到像 12500000.xxx 这样的巨大数字,所以进行数学运算以获得你需要的比率:1/12500000,你会得到比率 = 0.00000125
希望有帮助;)
PS 解码的 URL 更容易阅读,如下所示:
UPDATE: Yahoo API is not working anymore. Leaving this legacy answer just to provide information that this doesn't work anymore.
use yahoo api:
it will return json format like:
Check out in the URL there is USDLTL now, so just change to what you need.
Also sometime the rate is so low, that you don't see it even with 4 numbers it shows:
Rate: 0.0006
Do not panic just make a reversal query, flip your currencies and make some simple math.
e.g. you got that the rate is from KRW to EUR 0.0006 but the real rate is something like 0.00000125 so ask API again, just flip the currencies: what is the ratio from EUR to USD. then you will get huge number like 12500000.xxx so make math to get the ratio you need: 1/12500000 and you will get ratio = 0.00000125
Hope that helps ;)
P.S. decoded URL which is easier to read looks like this:
我使用 php 类来转换货币汇率:
I use a php-class to convert currency rates:
这是 Felix Geenen 答案的一个简单改编,使用 curl 而不是 fopen,因为很多服务器默认关闭 fopen。
(我清理了一些代码并添加了一个递减值来重试。)
(还记得根据您将函数放入的范围更新重试自引用,例如 static:: 或 $this-> )
Here is a simple adaptation of Felix Geenen's answer to use curl instead of fopen since a lot of servers have fopen turned off by default.
( I cleaned up some code and added a decrement value to retry. )
( Also remember to update the retry self reference depending on the scope you drop the function in to eg. static:: or $this-> )
我一直在使用 iGoogle,直到它崩溃了,这对我来说是对的。
感谢 Nerfair 在回应上面霍贝利的评论时的评论,这太棒了。我想我应该将其发布在这里,以便您可以充分了解它是如何工作的!
http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange 其中 ("USDCNY")&format=json&env=store 中的配对: //datatables.org/alltableswithkeys&callback=
这是编码的链接 url:http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28 %22USDCNY%22%29&format=json&env=store://datatables.org/alltableswithkeys&callback=
超级好,就这样更改货币对。谢谢内菲尔!
I was using iGoogle until it just went belly up, serves me right.
Thanks to Nerfair tho in his comment in response to hobailey's comment above, this works AWESOME. I thought I would post it here so you can fully see how it works!
http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("USDCNY")&format=json&env=store://datatables.org/alltableswithkeys&callback=
Here is the link url encoded: http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDCNY%22%29&format=json&env=store://datatables.org/alltableswithkeys&callback=
Super nice, just change the currency pair. Thanks Nerfair!