我在这里经历了很多关于使用外部 JSON 文件的不同线程,但当我运行脚本时,所有这些线程似乎都没有显示任何内容。
我正在尝试显示第一个 this JSON 网址。
原始数据:
{
"total_market_cap_usd": 178408752351.0,
"total_24h_volume_usd": 6196679281.0,
"bitcoin_percentage_of_market_cap": 57.24,
"active_currencies": 883,
"active_assets": 344,
"active_markets": 6243
}
不太确定如何去做。我看到一个教程建议使用 PHP:
<?
$url = 'https://api.coinmarketcap.com/v1/global/';
$data = file_get_contents($url);
$price = json_decode($data);
echo $price[1];
但这似乎也没有返回任何结果。
最佳答案
请查看API说明
$url = 'https://api.coinmarketcap.com/v1/global/';
$data = file_get_contents($url);
$price = json_decode($data,true);
//var_dump($price);
echo $price["total_market_cap_usd"];
关于javascript - 使用公共(public) JSON API 并将其显示为 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47011072/