1
如何从JSON url https://api.coinmarketcap.com/v1/ticker/ethereum/获取变量“price_usd”和“price_btc”?我写了一个脚本,但没有任何反应。如何使用PHP来获取和解码JSON数据?
<?php
$tick = file_get_contents('https://api.coinmarketcap.com/v1/ticker/ethereum/');
$url = $tick;
$json = file_get_contents($url);
$data = json_decode($json, TRUE);
$usd = $data[0]["price_usd"];
echo $usd;
?>
'的print_r($数据);' – AbraCadaver