mirror of
https://github.com/rottenwheel/moner.ooo.git
synced 2024-11-10 05:03:44 +01:00
feat: dynamically fetch and filter currencies list
Replaced the static list of currencies with a dynamic fetch from the CoinGecko API. Implemented a filter to exclude 'bits' and 'sats' from the fetched currencies. This ensures the currency list is always up-to-date and excludes unsupported currencies.
This commit is contained in:
parent
f475b4ff73
commit
9a09f86460
@ -3,14 +3,8 @@
|
||||
// Set default timezone
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
// Define the array of currencies
|
||||
$currencies = [
|
||||
"EUR", "BTC", "USD", "GBP", "CHF", "RUB", "CNY", "JPY", "IDR", "KRW", "TRY", "AUD",
|
||||
"BMD", "CAD", "HKD", "NZD", "SGD", "TWD", "ILS", "PLN", "ZAR", "CZK", "DKK", "NOK",
|
||||
"SEK", "ARS", "CLP", "PHP", "MXN", "BHD", "KWD", "BRL", "MYR", "VEF", "UAH", "VND",
|
||||
"BDT", "HUF", "MMK", "NGN", "THB", "AED", "SAR", "PKR", "LKR", "INR", "LTC", "ETH",
|
||||
"XAG", "XAU"
|
||||
];
|
||||
// Define currencies that should *not* be included in the list
|
||||
$excludedCurrencies = ['bits', 'sats'];
|
||||
|
||||
// Fetch the previously stored data
|
||||
$previousData = json_decode(file_get_contents("coingecko.json"), true);
|
||||
@ -18,6 +12,14 @@ $currentTime = time();
|
||||
|
||||
// Check if five seconds have passed since the last update
|
||||
if (($currentTime - $previousData['time']) >= 5) {
|
||||
// Fetch the available currencies from CoinGecko API
|
||||
$availableCurrencies = json_decode(file_get_contents("https://api.coingecko.com/api/v3/simple/supported_vs_currencies"), true);
|
||||
|
||||
// Remove excluded currencies
|
||||
$availableCurrencies = array_diff($availableCurrencies, $excludedCurrencies);
|
||||
|
||||
$currencies = array_map('strtoupper', $availableCurrencies);
|
||||
|
||||
// Fetch the latest data from CoinGecko API
|
||||
$apiUrl = 'https://api.coingecko.com/api/v3/simple/price?ids=monero&vs_currencies=' . implode('%2C', array_map('strtolower', $currencies)) . '&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user