我正在使用 Google 天气 API 和 PHP 获取条件:
http://www.google.com/ig/api?weather=New%20York
有没有办法改变:
<icon data="/ig/images/weather/partly_cloudy.gif"/>
自定义图像?
我正在使用 Google 天气 API 和 PHP 获取条件:
http://www.google.com/ig/api?weather=New%20York
有没有办法改变:
<icon data="/ig/images/weather/partly_cloudy.gif"/>
自定义图像?
正如<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';
}
最简单的方法是使用str_replace("google_path","your_path")
.