mirror of
https://github.com/rottenwheel/moner.ooo.git
synced 2025-04-29 11:59:28 -04:00
parent
a34a2bb487
commit
20e41d40a0
1 changed files with 8 additions and 1 deletions
|
@ -11,6 +11,13 @@ function fetchJson($filename) {
|
||||||
return json_decode(file_get_contents($filename), true);
|
return json_decode(file_get_contents($filename), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetchCache(string $key, string $url)
|
||||||
|
{
|
||||||
|
return apcu_entry($key, function() use ($url) {
|
||||||
|
return makeApiRequest($url);
|
||||||
|
}, 60);
|
||||||
|
}
|
||||||
|
|
||||||
// Make an API request and return the JSON response
|
// Make an API request and return the JSON response
|
||||||
function makeApiRequest($url) {
|
function makeApiRequest($url) {
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
@ -72,7 +79,7 @@ function fetchAvailableCurrencies() {
|
||||||
// Fetch currency data from CoinGecko API
|
// Fetch currency data from CoinGecko API
|
||||||
function fetchCurrencyData($currencies) {
|
function fetchCurrencyData($currencies) {
|
||||||
$apiUrl = getCoinGeckoApiUrl('simple/price', ['ids' => 'monero', 'vs_currencies' => implode(',', array_map('strtolower', $currencies))]);
|
$apiUrl = getCoinGeckoApiUrl('simple/price', ['ids' => 'monero', 'vs_currencies' => implode(',', array_map('strtolower', $currencies))]);
|
||||||
return makeApiRequest($apiUrl);
|
return fetchCache('currency_data', $apiUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
$currencyFile = 'coingecko.json';
|
$currencyFile = 'coingecko.json';
|
||||||
|
|
Loading…
Add table
Reference in a new issue