Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 833
MachineElf Avatar asked Jul 21 '13 15:07

MachineElf


People also ask

How google currency converter works?

How it works. Currency conversion automatically converts the price in your product data to the currency of the new target country and displays both prices in your ads and free product listings.

How do I add Google currency to my website?

Get Started with Google Shopping Currency Conversion Tool All you need to do is create an extra Google export and rename it. Then head to your Merchant Center and under the Shopping ads > Configuration you will find the currency converter switch and you can start your upload.


1 Answers

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.

like image 91
Simon Davies Avatar answered Sep 28 '22 10:09

Simon Davies