I have a problem getting data via api. When the crypto == "BTC" or "LTC", and everything works as it should, but in other cases the balance = NULL, you do not know what it could be? Here's code:
if ($krypto == "BTC") {
$json = file_get_contents('https://api.blockcypher.com/v1/btc/main/addrs/1BSJxTKxu2RZfHCtEFpXShypn73Xmpry6N/balance');
}
elseif ($krypto == "LTC") {
$json = file_get_contents('https://api.blockcypher.com/v1/ltc/main/addrs/LgzoEpUijQ39bWuY8XXQ2NUqrerebdE3w9/balance');
}
elseif ($krypto == "ETH") {
$json = file_get_contents('https://api.blockcypher.com/v1/eth/main/addrs/0x7d8b9d28d373394fb23242eb838345f69c2ec25d/balance');
}
elseif ($krypto == "DASH") {
$json = file_get_contents('https://api.blockcypher.com/v1/dash/main/addrs/XfUYFuyaca53cZHvJ9q679RqEo58wNRthp/balance');
}
elseif ($krypto == "DOGE") {
$json = file_get_contents('https://api.blockcypher.com/v1/doge/main/addrs/DCrzwReRzPuaipX1ziQoTiLqotLD3sKMUz/balance');
}
$obj = json_decode($json);
$balance = $obj->balance / 100000000;
question from:
https://stackoverflow.com/questions/65905396/when-obtaining-data-from-api-get-in-some-instances-null 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…