1

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?

John Slegers
  • 45,213
  • 22
  • 199
  • 169
TheNone
  • 5,684
  • 13
  • 57
  • 98
  • **The Google weather API was shut down in 2012** -> http://stackoverflow.com/questions/12145820/google-weather-api-gone/35943521 – John Slegers Mar 11 '16 at 15:55

2 Answers2

4

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';
}
Björn Kaiser
  • 9,882
  • 4
  • 37
  • 57
1

The simplest way is using str_replace("google_path","your_path").

NikiC
  • 100,734
  • 37
  • 191
  • 225
kraiosis
  • 46
  • 1
  • Hi! If you want to show that something is code you should enclose it in backticks (`\`your code\``) or, if it is a large block of code, indent it by four spaces. That way your post will be easier to read. – NikiC May 02 '11 at 17:29