phpapiweatherweather-apigoogle-weather-api

Google Weather API and Using Custom image


I am using Google weather API and PHP for fetch conditions:

http://www.google.com/ig/api?weather=New%20York

Is there any way for change:

<icon data="/ig/images/weather/partly_cloudy.gif"/>

to custom image?


Solution

  • As <icon data="/ig/images/weather/partly_cloudy.gif"/> is returned by the API (which is not an official API btw.) you could use an if statement in PHP to "replace" the image.

    if($theAPIResponse->icon->attributes()->data == '/ig/images/weather/partly_cloudy.gif') {
           // Override the nodes data attribute with your custom image
           $theAPIResponse->icon->attributes()->data = '/path/to/your/custom_image.gif';
    }