Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getExchangeRateYahoo( $currencyFrom, $currencyTo)
- {
- static $has_run;
- // if refresh = true
- // query yahoo for exchange rate
- if (!empty($has_run)) { sleep(1); }
- //$url = "http://quote.yahoo.com/d/quotes.csv?s={$currencyFrom}{$currencyTo}=X&f=l1&e=.csv";
- // $handle = @fopen($url, 'r');
- // if ($handle) {
- // $result = fgets($handle, 4096);
- // fclose($handle);
- // }
- /*
- Display current exchange rate requested by user.
- Copyleft ak47suk1(http://kaibathelegacy.blogspot.com)
- */
- $exchange_rates = json_decode(file_get_contents("http://openexchangerates.org/latest.json"));
- $result=$exchange_rates->rates->$currencyTo/$exchange_rates->rates->$currencyFrom;
- $rate = (float) $result * 1.0;
- $has_run = true;
- return $rate;
- }
Add Comment
Please, Sign In to add comment