Google currency converter API - will it shut down with iGoogle?

巧了我就是萌 提交于 2020-01-12 03:38:47

问题


iGoogle is shutting down.

There is an (undocumented?) currency conversion API available with URLs like: http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD

The base of this url - google.com/ig - takes you to iGoogle. Will the API be available after iGoogle shuts down?


回答1:


I was having the same issue described here: https://stackoverflow.com/a/19786423/2819754

I used @hobailey answer for a temporary fix until i can update it to another version or google decide to do a proper api.

As google changed the URL to

  https://www.google.com/finance/converter?a

So the fix i found is below.

  $amount = urlencode($amount);
  $from_Currency = urlencode($from_Currency);
  $to_Currency = urlencode($to_Currency);
  $get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
  $get = explode("<span class=bld>",$get);
  $get = explode("</span>",$get[1]);  
  $converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);

thanks to @hobailey for this little fix.




回答2:


Alternatively you can use following:

  • http://rate-exchange.appspot.com/currency?from=CAD&to=USD

  • http://rate-exchange.herokuapp.com/fetchRate?from=CAD&to=USD

But the first one is not that stable goes out of capacity very often. We had an extreme problem in our production environment using the first exchange service few months back. So far second one is stable, doesn't cause any problem.




回答3:


iGoogle has already expired but not the gadget link you have posted. Currently it returns 200 OK with probably your desired message.

Update: It got expired too. No Gadgets are available at the moment.

Update: Available from here https://www.google.com/finance/converter?a=16.6700&from=GBP&to=USD




回答4:


Free Currency Converter API from http://mycurrency.net

  • It is 100% Free.
  • No API key is required!
  • No cap on frequency of API calls.
  • Currency price is updated every two hours.
  • Support json format.
  • Very fast and reliable.
  • The api address is here. It returns 176 currencies prices together with country name, country code, currency name and currency price. The base currency is USD.

    http://www.mycurrency.net/service/rates

There is also Free country flag API you may also need. Just replace the country code.

http://caches.space/flags/{countrycode}.png

Example:

http://caches.space/flags/sg.png

http://caches.space/flags/us.png




回答5:


Just use this URL

https://finance.google.com/bctzjpnsun/converter?a=1&from=USD&to=INR

Replace

 https://www.google.com/finance/

to

https://finance.google.com/bctzjpnsun/


来源:https://stackoverflow.com/questions/17773898/google-currency-converter-api-will-it-shut-down-with-igoogle

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