Skip to content
Index Help & Support Faucet Owners Programming

Coinmarketcap API v2 for Faucethub Coins

Posted by freek.in 1 year ago
0 716
Coinmarketcap API v2 for Faucethub Coins
Posted 1 year ago
Use this function to get realtime market price of faucethub coins , use this function in your config.php or function.php files. function getValueOfFCoin($coinname) { if($coinname == 'BTC') { $coinnumber = 1; } else if($coinname == 'LTC') { $coinnumber = 2; } else if($coinname == 'DOGE') { $coinnumber = 74; } else if($coinname == 'ZEC') { $coinnumber = 1437; } else if($coinname == 'BTX') { $coinnumber = 1654; } else if($coinname == 'DASH') { $coinnumber = 131; } else if($coinname == 'ETH') { $coinnumber = 1027; } else if($coinname == 'PPC') { $coinnumber = 5; } else if($coinname == 'BLK') { $coinnumber = 170; } else if($coinname == 'POT') { $coinnumber = 122; } else if($coinname == 'XPM') { $coinnumber = 42; } else if($coinname == 'BCH') { $coinnumber = 1831; } else if($coinname == 'XMR') { $coinnumber = 328; } else if($coinname == 'DGB') { $coinnumber = 109; } $extract = file_get_contents('https://api.coinmarketcap.com/v2/ticker/'.$coinnumber.'/?convert=BTC'); $coinarray = json_decode($extract,true); $coinarray = $coinarray; $coinvalueinbtc = $coinarray; $coinvalueinusd = $coinarray; $returnvalue = $coinvalueinbtc.'+'.$coinvalueinusd; return $returnvalue; } Then use this code where you want your price to be used. #GETVALUE OF DOGE FROM COINMARKET# $dogevalue = getValueOfFCoin('DOGE'); $dogevalue = explode('+',$dogevalue); $dogevalueinbtc = $dogevalue; $dogevalueinusd = $dogevalue; echo 'DOGE value in BTC :'.$dogevalueinbtc.' & DOGE value in USD :'.$dogevalueinusd;