This is a pretty classic programming question, but I think it is a very common one for the Bitcoin community, and would be helpful to have the code publicly available. My preference is for a php script.
DOYOU NEED BITCOIN TRADING PLATFORM, CALL WAKABIA ICT +2347063076212
DOYOU NEED BITCOIN TRADING PLATFORM, CALL WAKABIA ICT +2347063076212
or click here to see all our already made PHP Website scripts
https://www.wakabiang.com/2020/05/buy-already-made-php-scripts-for-your.html
Bitpay publishes it's exchange rates here: https://bitpay.com/api/rates
If an item is $10 USD, how would I do the following?
1) extract the BTC/USD exchange rate from the array at this URL
2) Define the price, then divide by the exchange rate
3) Display the BTC price in an HTML page?
Bitpay publishes it's exchange rates here: https://bitpay.com/api/rates
If an item is $10 USD, how would I do the following?
1) extract the BTC/USD exchange rate from the array at this URL
2) Define the price, then divide by the exchange rate
3) Display the BTC price in an HTML page?
WARNING: RUN THE BELOW CODE ON THE LIVE SERVER (If possible let the server has https enabled)
<html>
<head><title>Bit calc</title>
</head>
<body>
<?php
$url = "https://bitpay.com/api/rates";
$json = file_get_contents($url);
$data = json_decode($json, TRUE);
$rate = $data[1]["rate"];
$usd_price = 10; # Let cost of elephant be 10$
echo $bitcoin_price = round( $usd_price / $rate , 8 );
?>
<ul>
<li>Price: <?php echo '='.$usd_price; ?> $ / <?php echo '='.$bitcoin_price; ?> BTC
</ul>
</body>
</html>
SHARE THIS POST
0 comments:
Post a Comment