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

天涯浪子 提交于 2019-12-03 04:08:34
Simon Davies

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.

Alternatively you can use following:

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.

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

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

Hisanth

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