Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 谷歌天气api问题_Php_Weather Api_Google Weather Api - Fatal编程技术网

Php 谷歌天气api问题

Php 谷歌天气api问题,php,weather-api,google-weather-api,Php,Weather Api,Google Weather Api,我在使用google weather api时遇到问题,我已经使用此脚本一段时间了,但之前我遇到了以下错误: 警告:simplexml\u加载\u文件() [function.simplexml加载文件]: //www.google.com/ig/api?weather=百慕大:2: 分析器错误:开始和结束标记 不匹配:元行1和头输入 /home/webmx04/public_html/weather/widgetlive1.php 在线3 警告:simplexml\u加载\u文件() [fun

我在使用google weather api时遇到问题,我已经使用此脚本一段时间了,但之前我遇到了以下错误:

警告:simplexml\u加载\u文件() [function.simplexml加载文件]: //www.google.com/ig/api?weather=百慕大:2: 分析器错误:开始和结束标记 不匹配:元行1和头输入 /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [function.simplexml加载文件]: 302移动 在里面 /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [函数.simplexml加载文件]:^in /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [function.simplexml加载文件]: //www.google.com/ig/api?weather=百慕大:6: 分析器错误:开始和结束标记 不匹配:中的头行1和HTML /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [function.simplexml加载文件]: 在里面 /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [函数.simplexml加载文件]:^in /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [function.simplexml加载文件]: //www.google.com/ig/api?weather=百慕大:7: 分析器错误:数据提前结束 在标签HTML中的第1行 /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [function.simplexml加载文件]:在 /home/webmx04/public_html/weather/widgetlive1.php 在线3

警告:simplexml\u加载\u文件() [函数.simplexml加载文件]:^in /home/webmx04/public_html/weather/widgetlive1.php 在线3

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

有人能帮我吗谢谢

我的代码:

<?
$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>
xpath(“/xml\u api\u reply/weather/forecast\u information”);
$current=$xml->xpath(“/xml\u api\u reply/weather/current\u conditions”);
$forecast\u list=$xml->xpath(“/xml\u api\u reply/weather/forecast\u conditions”);
?>
谷歌天气API

显然,谷歌在其天气API中引入了验证码。它将工作一次、两次或三次,但在同一服务器发出少量请求后,它将要求复制验证码。你的插件不能做的事情

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


缓存Google Weather的结果也可能有所帮助。15或30分钟内的1个请求应该可以接受,否?

查看您标记的源不匹配表示标记未关闭或关闭位置不正确您好,谢谢您的回复,但您所说的不匹配是什么意思我通过上面的代码添加的您能看到我做错了什么吗,我只是不知道是什么问题,演示在工作正常,但当我复制粘贴到我的主机它只是给我的一些原因,它的修复本身,我不知道发生了什么现在它又坏了,我不知道是什么原因造成这个问题