Im trying to extract the file from this url (http://chainz.cryptoid.info/cbx/api.dws?q=getdifficulty) which shows a number but I can't seem to display it. Is there a problem in my code or is it in the site that I'm getting it from?
Here's my code:
<?php
$url = "http://chainz.cryptoid.info/cbx/api.dws?q=getdifficulty";
$data = json_decode(file_get_contents($url), true);
echo "$data";
?>
It only shows null, can you please help?
Once the above is being answered, I would like to try using a bigger content from this url (http://chainz.cryptoid.info/cbx/api.dws?q=lasttxs&a=5h9ZZpokW2P15yXr66MsHKknPvYmECvaDF)
Here's my code below:
<?php
$url = "http://chainz.cryptoid.info/cbx/api.dws?q=lasttxs&a=5h9ZZpokW2P15yXr66MsHKknPvYmECvaDF";
$data = json_decode(file_get_contents($url), true);
$content = $data[0]; //trying to get the 1st row
$hash = $content['hash'];
echo "$hash";
?>
The code is not showing anything. Can you please help in displaying the value using php? Thanks
This code though is working ok:
<?php
$url = "https://www.cryptonator.com/api/ticker/cbx-usd";
$data = json_decode(file_get_contents($url), true);
$ticker = $data['ticker'];
$latest_price = $ticker['price'];
echo "$latest_price";
?>