Skip to content

Commit

Permalink
Migrate to NPM Free Currency Exchange Rates API
Browse files Browse the repository at this point in the history
GitHub made the creator remove the code, so they moved it to NPM.

fawazahmed0/exchange-api#89
  • Loading branch information
gregdotca committed Aug 6, 2024
1 parent 69cdd36 commit 19f4128
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// era = http://exchangeratesapi.io
// er-a = https://www.exchangerate-api.com
// erh = https://exchangerate.host
// fcra = https://github.com/fawazahmed0/currency-api -- NO API KEY REQUIRED!
// fcra = https://github.com/fawazahmed0/exchange-api -- NO API KEY REQUIRED!
// fixer = https://fixer.io
// interzoid = https://interzoid.com
$converter_source = 'fcra';
Expand Down
4 changes: 2 additions & 2 deletions src/GJClasses/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public function getConvRate($from_currency, $to_currency)
$from_currency = strtolower($from_currency);
$to_currency = strtolower($to_currency);

$full_url = 'https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/' . $from_currency . '/' . $to_currency . '.json';
$full_url = 'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/' . $from_currency . '.json';
$remote = new Remote();
$result = $remote->getFileContents($full_url);
if ($result === false) return false;
$json_result = json_decode($result, true);
$conversion_rate = $json_result[$to_currency];
$conversion_rate = $json_result[$from_currency][$to_currency];

} elseif ($this->source === 'fixer') {

Expand Down

0 comments on commit 19f4128

Please sign in to comment.