People need to get data from a JSON file (I'm not the fuck in the business). This api below is for displaying temperature via JSON + PHP, remembering that on the same site I can not get the maximum, minimum or display days of the week, but this data is in JSON, but how do I display them?
<?php
/*
* Obtendo dados do HG Weather API
*
* Consulte nossa documentacao em http://hgbrasil.com/weather
* Contato: [email protected]
* Copyright 2015 - Hugo Demiglio - @hugodemiglio
*
*/
$cid = 'BRXX0198'; // CID da sua cidade, encontre a sua em http://hgbrasil.com/weather
$dados = json_decode(file_get_contents('http://api.hgbrasil.com/weather/?cid='.$cid.'&format=json'), true);
// Recebe os dados da API
?>
Below I'll leave it to you how I can display the other values.
<?php echo $dados['results']['city_name']; ?>
<?php echo $dados['results']['temp']; ?>
More below you can see the JSON file formatted to understand better and also his link Online
{
"by":"cid",
"valid_key":false,
"results":{
"temp":23,
"date":"12/04/2017",
"time":"09:11",
"condition_code":"32",
"description":"Ensolarado",
"currently":"dia",
"cid":"",
"city":"Ribeirao Preto,",
"img_id":"32",
"humidity":"76",
"wind_speedy":"11.27 km/h",
"sunrise":"6:22 am",
"sunset":"6:2 pm",
"condition_slug":"clear_day",
"city_name":"Ribeirao Preto",
"forecast":[
{
"date":"12/04",
"weekday":"Qua",
"max":"28",
"min":"20",
"description":"Tempestades",
"condition":"storm"
},
{
"date":"13/04",
"weekday":"Qui",
"max":"28",
"min":"18",
"description":"Parcialmente nublado",
"condition":"cloudly_day"
},
{
"date":"14/04",
"weekday":"Sex",
"max":"29",
"min":"18",
"description":"Tempestades isoladas",
"condition":"storm"
},
{
"date":"15/04",
"weekday":"Sáb",
"max":"30",
"min":"18",
"description":"Ensolarado com muitas nuvens",
"condition":"cloudly_day"
},
{
"date":"16/04",
"weekday":"Dom",
"max":"30",
"min":"18",
"description":"Parcialmente nublado",
"condition":"cloudly_day"
},
{
"date":"17/04",
"weekday":"Seg",
"max":"26",
"min":"18",
"description":"Tempestades isoladas",
"condition":"storm"
},
{
"date":"18/04",
"weekday":"Ter",
"max":"28",
"min":"19",
"description":"Tempo nublado",
"condition":"cloud"
},
{
"date":"19/04",
"weekday":"Qua",
"max":"27",
"min":"20",
"description":"Tempestades",
"condition":"storm"
},
{
"date":"20/04",
"weekday":"Qui",
"max":"21",
"min":"19",
"description":"Tempestades isoladas",
"condition":"storm"
},
{
"date":"21/04",
"weekday":"Sex",
"max":"22",
"min":"16",
"description":"Tempestades isoladas",
"condition":"storm"
}
]
},
"execution_time":0.0,
"from_cache":true
}