I'm working on a wunderground weather intergration for a website and I would like to change/edit parts of the request URL for the API. I've tried a couple of solutions I found here on Stack overflow, but none have worked.
$state = 'NC';
$city = 'Boone';
$json_string = file_get_contents("https://api.wunderground.com/api/MY-API-KEY/geolookup/conditions/q/'.$state.'/'.$city.'.json");
$parsed_json = json_decode($json_string);
$location = $parsed_json->{'location'}->{'city'};
$temp_f = $parsed_json->{'current_observation'}->{'temp_f'};
echo "Current temperature in ${location} is: ${temp_f}\n";
I can't seem to figure it out. As you can see, I'm trying to make the state and city URL placements editable, (state & city).
It will output this:
Current temperature in [city name] is: [temp]
Any thoughts on how to edit the request URL?
$stateand$cityserve your needs ?"and'in the query string, where you put your variables...