1

I used this link to fetch the pound to euro exchange rate on a daily (nightly) basis:

http://www.google.com/ig/calculator?hl=en&q=1pound=?euro

This returned an array which I then stripped and used the data I needed.

Since the first of November they retired iGoogle resulting in the URL to forward to: https://support.google.com/websearch/answer/2664197

Anyone knows an alternative URL that won't require me to rewrite the whole function? I'm sure google didn't stop providing this service entirely.

Dominique
  • 1,080
  • 14
  • 29
  • See: http://stackoverflow.com/questions/3139879/how-do-i-get-currency-exchange-rates-using-google-finance-api – subZero Nov 06 '13 at 15:22

1 Answers1

1

I started getting cronjob errors today on this very issue. So I fell back to a prior URL I was using before I switched to the faster/reliable iGoogle.

Url to programmatically hit (USD to EUR): http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=EUR

Details about it: http://www.webservicex.net/ws/WSDetails.aspx?CATID=2&WSID=10

It works for now, but its prone to be slow at times, and used to respond with an "Out of space" error randomly. Just be sure to code in a way to handle that, and maybe run the cron four times a day instead of once. I run ours every hour.

Example code to get the rate out of the return (there is probably a more elegant way):

$ci = curl_init($accessurl);
curl_setopt($ci, CURLOPT_HTTPGET, 1);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1);
$rawreturn = curl_exec($ci);
curl_close($ci);
$rate = trim(preg_replace("/.*<double[^>]*>([^<]*)<\/double[^>]*>.*/i","$1",$rawreturn));
IncredibleHat
  • 4,000
  • 4
  • 15
  • 27
  • I know this is an old post, but I wanted to followup that we had moved entirely to using currencylayer API (we do the first paid tier, which is cheap for a business, but the free tier works great for personal sites). It cleared up the guesswork if the url parsing locations will work, or continue to work. – IncredibleHat Aug 30 '17 at 13:28