谷歌API天气预报和使用自定义图像 [英] Google Weather API and Using Custom image
本文介绍了谷歌API天气预报和使用自定义图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用谷歌API的天气和PHP的获取条件:
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"/>
自定义形象?
推荐答案
由于&LT;图标数据=/ IG /图像/天气/ partly_cloudy.gif/&GT;
由API返回(这不是一个官方的API BTW)。你可以使用if语句在PHP中替换的形象。
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';
}
这篇关于谷歌API天气预报和使用自定义图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文