I have read and tried some code that I found in other posts with similar issues but I couldn't find a solution.
I'm using this API: https://api.ipma.pt/open-data/forecast/meteorology/cities/daily/1100900.json which returns this:
{
"owner": "IPMA",
"country": "PT",
"data": [
{
"precipitaProb": "0.0",
"tMin": "12.6",
"tMax": "24.0",
"predWindDir": "N",
"idWeatherType": 3,
"classWindSpeed": 2,
"longitude": "-8.8069",
"forecastDate": "2020-05-22",
"latitude": "39.7473"
},
{
"precipitaProb": "0.0",
"tMin": "13.1",
"tMax": "24.2",
"predWindDir": "N",
"idWeatherType": 5,
"classWindSpeed": 2,
"longitude": "-8.8069",
"forecastDate": "2020-05-23",
"latitude": "39.7473"
},
{
"precipitaProb": "0.0",
"tMin": "12.8",
"tMax": "26.5",
"predWindDir": "NW",
"idWeatherType": 2,
"classWindSpeed": 1,
"longitude": "-8.8069",
"forecastDate": "2020-05-24",
"latitude": "39.7473"
},
{
"precipitaProb": "0.0",
"tMin": "13.4",
"tMax": "26.0",
"predWindDir": "NW",
"idWeatherType": 5,
"classWindSpeed": 1,
"longitude": "-8.8069",
"forecastDate": "2020-05-25",
"latitude": "39.7473"
},
{
"precipitaProb": "3.0",
"tMin": "16.3",
"tMax": "31.7",
"predWindDir": "E",
"idWeatherType": 2,
"classWindSpeed": 2,
"longitude": "-8.8069",
"forecastDate": "2020-05-26",
"latitude": "39.7473"
}
],
"globalIdLocal": 1100900,
"dataUpdate": "2020-05-22T14:31:04"
}
I need to get several values from the "data" array.
So far i have this:
<?php
$api_url = file_get_contents('https://api.ipma.pt/open-data/forecast/meteorology/cities/daily/1100900.json');
$forecastLeiria = json_decode($api_url);
var_dump($forecastLeiria);
?>
Returns NULL even tho the API is working just fine.
Cheers!