Hello, at some time, this problem with organizing the json_decoce api rest
Today, I have a problem with the rest of the api api that I use, the main content is in other keys
Ex:
{"status": "success" {"Name": "Teacher", "id": "1"}}
I wanted to get the contents of this internal key, which is what interests me the most, my code does not answer:
<?php
$bin = $_POST['bin'];
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "https://api.freebinchecker.com/bin/$bin");
// $output contains the output json
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
// {"name":"Baron","gender":"male","probability":0.88,"count":26}
$bin = json_decode($output, false);
?>
I have already added a similarity to this one, but do not get it too:
<?php
$cep = $_POST['cep'];
$ch = file_get_contents("http://apps.widenet.com.br/busca-cep/api/cep/$cep.json");
$retorno=json_decode($ch, true);
//aqui retorna array
//print_r($retorno);
echo "Status: ";
echo $retornoStatus=$retorno['status'];
echo "<br>";
echo "Estado: ";
echo $retornoEstado=$retorno['state'];
echo "<br>";
echo "Cidade: ";
echo $retornoCidade=$retorno['city'];
echo "<br>";
echo "Distrito: ";
echo $retornoDistrito=$retorno['district'];
echo "<br>";
echo "Endereço: ";
echo $retornoEndereco=$retorno['address'];
echo "<br>";
?>
Could you help me?