Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

php - When obtaining data from api get in some instances NULL

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...