Help I cant parse the info

  • 1
  • Question
  • Updated 7 years ago
http://api.wunderground.com/api/yourk...

I want to get the info at the bottom under dailysummary and maxtempi I am using

$json_string = file_get_contents("http://api.wunderground.com/api/yourkey here/history_20120515/q/pws:KCABURNE1.json");

But i cant get it to pull this data. I can pull data from everywhere else i query just not here any help Greatly appricated
$parsed_json = json_decode($json_string);

$maxtempi = $parsed_json->{'dailysummary'}->{'maxtempi'};

echo "      Max Temp is: ${maxtempi}      \n";

Any help would be greatly appreciated
Photo of wjcable

wjcable

  • 5 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 1
Photo of juanbond

juanbond

  • 20 Posts
  • 8 Reply Likes
You just need to examine the structure of the returned JSON more closely. "dailysummary" is not simply at the top level, thus why you can't retrieve it the way you are attempting. Try this instead:

$maxtempi = $parsed_json->{'history'}->{'dailysummary'}[0]->{'maxtempi'};
Photo of wjcable

wjcable

  • 5 Posts
  • 0 Reply Likes
YOU ROCK. THANKS FOR THAT. WORKS LIKE A CHARM.