Forecast api call in PHP

  • 1
  • Question
  • Updated 6 years ago
unable to use show forecast api call,
the sample code given in this website is not working for me.

can anybody help.

i am using the below code -

$day = $parsed_json->{'forecast'}->{'title'};
echo "Day : $day\n";
Photo of ManishPal

ManishPal

  • 3 Posts
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
try this:

print_r($parsed_json->{'forecast'}->{'txt_forecast'});
$day = $parsed_json->{'forecast'}->{'txt_forecast'}->{'forecastday'}[0]->{'title'};
echo "Day : $day\n";
Photo of ManishPal

ManishPal

  • 3 Posts
  • 0 Reply Likes
Your email went spam folder, apologize to reply you late.
Yes, it is working fine now.

Thanks Brendan.
Photo of ManishPal

ManishPal

  • 3 Posts
  • 0 Reply Likes
One more question.

how to show the nearby weather station.

For the city of Mumbai, India - nearby weather station should come as "Mumbai / Santacruz".

i am having a blank output (it is showing nothing).

using the below code -
$weatherstation = $parsed_json->{'location'}->{'airport'};
echo "Nearby Weather Station : $weatherstation";
Photo of ralphiboy74

ralphiboy74

  • 1 Post
  • 0 Reply Likes
I have a similar issue with the API, I would like to display the Forecast Day 1 ICON.

Current code does not work...:

$icon1 = $parsed_json->{'forecast'}->{'txt_forecast'}->{'forecastday'}[1]->{'icon_url'};
echo "***** Icon: *****";

Any help is welcome. Thank you! Ralph