How to Make Bitcoin Calculator Using Rupiah Rates
How to Make a Bitcoin Calculator. Halo Bitcoiner, probably part of my
friends already know how to make a Bitcoin price converter calculator. But
for friends who do not know it, can listen to the way below.
Further friends can also put it into blog or site friends. visitors who want to convert Bitcoin into rupiah, can use the calculator that has been made. Here the EB makes for the wordpress, so it will require a PHP Code plugin to run the conventer.
You can install PHP Code Snippets first. If so, here's how to create a Bitcoin calculator:
- Take the Bitcoin Price Ticker API. Because we need the exchange rate in Rupiah, we can take the public API of Bitcoin Price Ticker from VIP Bitcoin Indonesia exchanger. The term, take the last price position, or commonly called "Get Current Price" . And here is the VIP Bitcoin Indonesia API. https://vip.bitcoin.co.id/api/btc_idr/ticker .
- If we click on the public ticker api, then there will be some information related to Bitcoin price since then. But my friends try not too often merequest ticker price. At least 1-5 minutes interval is not a problem, so as not to overburden.
- All we need is the last price through API Ticker price in the VIP BITCOIN. Namely on "last" which shows the position of the last price. But can also be developed alone if you need volume quantity (vol_btc) , the highest price (high), the purchase price (buy), or also the selling price (sell) .
- Now go in the PHP Code plugin, and create a new snippet. Then copy and paste the following code:
<?php
function getPrice($url){
$decode = file_get_contents($url);
return json_decode($decode, true);
}
$btcIDR = getPrice(‘https://vip.bitcoin.co.id/api/btc_idr/ticker’);
$btcPrice = $btcIDR[“ticker"][“last"];
$btcDisplay = round($btcPrice,2);
$angka = $btcPrice;
$format_angka = number_format($btcPrice, “2",",",".");
?>
$btcIDR = getPrice(‘https://vip.bitcoin.co.id/api/btc_idr/ticker’);
$btcPrice = $btcIDR[“ticker"][“last"];
$btcDisplay = round($btcPrice,2);
$angka = $btcPrice;
$format_angka = number_format($btcPrice, “2",",",".");
?>
<html>
<body>
<head>
<style>
h1 {
font-family: “Calibri", Arial, sans-serif;
font-size: 60px;
}
h2 {
font-family: “Calibri", Arial, sans-serif;
font-size: 32px;
}
#container {
font-family: “Calibri", Arial, sans-serif;
font-size: 42px;
border:4px solid #999999;
border-radius: 6px;
height: 65px;
width: 600px;
}
#bi, #ci {
font-family: “Calibri", Arial, sans-serif;
font-size: 24px;
border:1px solid #666666;
border-radius: 4px;
height: 50px;
width: 200px;
margin-top: 3px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<center>
<h1>Harga Bitcoin</h1>
<h2><?php echo “Rp. “.$format_angka; ?> / 1 Bitcoin</h2>
<script>
function btcConvert(input){
if (isNaN(input.value)){
input.value = 0;
}
var price = “<?php echo $btcDisplay; ?>";
var output = input.value * price;
var co = document.getElementById(‘ci’);
ci.value=output.toFixed(2);
}
function idrConvert(input){
if (isNaN(input.value)){
input.value = 0;
}
var price2 = “<?php echo $btcDisplay; ?>";
var output2 = input.value / price2;
var co2 = document.getElementById(‘bi’);
bi.value=output2.toFixed(8);
}
</script>
<div id="container">
<input type="text" name="bi" id="bi" onchange="btcConvert(this);" onkeyup="btcConvert(this);"/> BTC = <input type="text" name="ci" id="ci" onchange="idrConvert(this);" onkeyup="idrConvert(this);" /> IDR
</div>
</body>
- You can first test the code whether it can run or not in PHPfiddle .
- Then if you've created a new snippet, name the new snippet, then take the shortcode.
- With the shortcode, you can post it in a new post, or on a separate page. In accordance with what you want.
- And the Bitcoin Price Calculator is ready.You can try it yourself. Easy is not it?
Please take here the complete code >>> Bitcoin Calculator That's how to make a bitcoin calculator. Hopefully useful, and good luck.