首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google天气api问题

google天气api问题
EN

Stack Overflow用户
提问于 2011-04-06 15:10:33
回答 1查看 1.6K关注 0票数 0

我在谷歌天气api上遇到了问题,我使用这个脚本http://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/已经有一段时间了,但是之前我遇到了这个错误:

/home/webmx04/public_html/weather/widgetlive1.php警告: simplexml_load_file() simplexml_load_file() function.simplexml-load-file: //www.google.com/ig/api?

=百慕大:2:解析器错误:开始和结束标记错配:元行1和第3行的

警告:在第3行的/home/webmx04/public_html/weather/widgetlive1.php中移动了simplexml_load_file() Function.simplexml-load文件: 302

警告: /home/webmx04/public_html/weather/widgetlive1.php第3行中的simplexml_load_file() Function.simplexml-load文件:^

警告: simplexml_load_file() function.simplexml-load-file: //www.google.com/ig/api?天气=百慕大:6:解析器错误:开始和结束标记不匹配:第1行和第3行中的simplexml_load_file

警告: /home/webmx04/public_html/weather/widgetlive1.php第3行中的simplexml_load_file() Function.simplexml-load文件:

警告: /home/webmx04/public_html/weather/widgetlive1.php第3行中的simplexml_load_file() Function.simplexml-load文件:^

警告: simplexml_load_file() simplexml_load_file() function.simplexml-load-file: //www.google.com/ig/api?天气=百慕大:7:解析器错误:在第3行的标签HTML第1行中数据过早结束

警告: /home/webmx04/public_html/weather/widgetlive1.php第3行中的simplexml_load_file() Function.simplexml-load文件:

警告: /home/webmx04/public_html/weather/widgetlive1.php第3行中的simplexml_load_file() Function.simplexml-load文件:^

致命错误:在第4行的/home/webmx04/public_html/weather/widgetlive1.php中调用非对象上的成员函数xpath()

有人能帮我谢谢你吗

我的代码:

代码语言:javascript
复制
<?
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=bermuda');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
?>
<html>
<head>
    <title>Google Weather API</title>
</head>
<body>
<div id="widget-wrapper"><!-- start widget-wrapper-->
 <div class="weather"><!-- start weather--> 

         <h2><a href="/section/weather" title="More on Weather" target="_top">Current Weather</a></h2>  
           <a href="/section/weather" target="_top"><img src="<?= 'http://www.rgbdahosting.com' . $current[0]->icon['data']?>" alt="More on Weather"?></a>
            <span class="condition">
          <a href="/section/weather" title="More on Weather" target="_top"><H4><?= $current[0]->temp_f['data'] ?>&deg;F</H4>

           <p><?= $current[0]->condition['data'] ?></p></a>
            </span>
        </div><!-- end weather-->

</div>  <!-- end widget-wrapper-->
</body>
EN

回答 1

Stack Overflow用户

发布于 2012-08-08 13:30:55

显然,谷歌将Captcha引入了他们的天气API。它将工作一次、两次或三次,但在同一服务器很少请求之后,它将要求复制Captcha。一些你的插件做不到的事情。

我不知道如何解决这个问题,所以看起来我们必须找到另一个使用的气象API。如果我错了,请纠正我,这会有帮助的。

谷歌天气的缓存结果也可能会有所帮助。1在15或30分钟内的请求应该是可以接受的,不是吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5568670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档