我想从 API 打印结果......但它不工作......我不知道有什么问题我试图这样做但得到了这个并且它不工作:
<?php
$api = 'https://api.battlemetrics.com/servers/'; // the main API for servers.
$server = '5090469'; // the number of the server you will get the info from most of thime something like 5484856.
$api_full = $api . $server; // bringing them together.
$json = file_get_contents("$api_full"); // Putting the content of the file in a variable.
$response = json_decode($json, true); // decode the JSON feed
if ($response['data']['status'] == "online") {
echo "ONLINE";
} else {
echo "OFFLINE";
};
?>
如果您想查看 json 响应,请附加以下链接:https ://api.battlemetrics.com/servers/5090469
提前感谢您的提示和帮助。
慕村9548890