1

我正在使用 Google 天气 API 和 PHP 获取条件:

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

有没有办法改变:

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

自定义图像?

4

2 回答 2

4

正如<icon data="/ig/images/weather/partly_cloudy.gif"/>API(顺便说一句,它不是官方 API)返回的那样,您可以在 PHP 中使用 if 语句来“替换”图像。

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';
}
于 2011-01-16T15:50:25.337 回答
1

最简单的方法是使用str_replace("google_path","your_path").

于 2011-05-02T01:55:19.517 回答