0

how can i get and show below link data, can someone please help me

https://runcoders.com/live-bitcoin/

i am trying by this but failed to show like up link

<?php
//define API endpoint
$url = "https://api.gdax.com/products/BTC-USD/stats";

//fetch the url and convert the JSON into an associative array
$fgc = json_decode(file_get_contents($url), true);

//assign values to variables
$open = $fgc["open"];
$high = $fgc["high"];
$low = $fgc["low"];
$close = $fgc["close"];
?>
<html>
<h1>My Website</h1>
<p>Bitcoin 24 HR stats</p>
Open: $<?php echo $open; ?><br>
High: $<?php echo $high; ?><br>
Low: $<?php echo $low; ?><br>
Close: $<?php echo $close; ?><br>
</html>
0

They are just using websocket to connect to the exchange and then outputting the lives trades to the page by appending it to an element.

Here's a simple example using bitfinex:

<html>
<div id="btc"></div>
<script>
var ws = new WebSocket("wss://api2.bitfinex.com:3000/ws");
ws.onopen = function(){
  ws.send(JSON.stringify({"event":"subscribe", "channel":"ticker", "pair":"BTCUSD"}))
};
ws.onmessage = function(msg){
  var response = JSON.parse(msg.data);
  var hb = response[1];
  if(hb != "hb"){
    document.getElementById("btc").innerHTML = "$" + response[7];
  }
};
</script>
</html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.