How can I use the API for the 10 day forcast for my own location (IDRENTHE59) in Dutch?

  • 1
  • Question
  • Updated 4 years ago
Photo of Weervrouw

Weervrouw

  • 5 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
according the posted datas in title,

http://api.wunderground.com/api/___WUAPIKEY___/forecast10day/lang:NL/q/pws:IDRENTHE59.json

can be an usable option for URL to hit
Photo of Weervrouw

Weervrouw

  • 5 Posts
  • 0 Reply Likes
Thank you very much. I'm gonne try to fix it. Never used an API or json before.
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
You're welcome.

You may find helpful for basic code usages in the documentation area at http://www.wunderground.com/weather/a... .

To consume this type of API just think as you were reading a remote file, with a custom structure. If you're using recent version of php you're lucky, once successfully obtained a remote JSON response, there are useful built in functions to help in translating into a PHP array/dictionary structure.
Photo of Weervrouw

Weervrouw

  • 5 Posts
  • 0 Reply Likes
I tried to add the script but it displayed only the second half. Now again.
{'location'}->{'city'};
$temp_f = $parsed_json->{'current_observation'}->{'temp_f'};
echo "Huidige temperatuur in ${location} is: ${temp_f}\n";
?>
Photo of Weervrouw

Weervrouw

  • 5 Posts
  • 0 Reply Likes
Thats terrible. The first half of the script will not display.
Photo of Weervrouw

Weervrouw

  • 5 Posts
  • 0 Reply Likes
What I want to say is that the suggestion doesn't display the data.
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Im not sure if it could be wrong or if the code can be tricky to be clear to understan.

Checked again the URL to call, so replacing in place a working key the response is returned correctly in dutch (or so the strings appear to be) for the ten days forecast feature; so even if this may not be the best place to find suitable software pattern blocks, a focus is anyway needed over programming logic.

The example fits well just only when requesting sample features, like conditions, so for data spanning multiple dates you should be able to figure out you can extend that code with a loop.
The "starring" php function is json_decode( http://www.php.net/json_decode ), so first it should be clear you can use it in your environment and maybe i'ts better to get confident with a basic usage of json_decode before anything else.

The idea is to let you reference the JSON path as a data tree: a quick trigger of inspection tool in your favourite browser (like the following image) would help you in fastest development process, even if API documentation is poor and can drive you crazy