2011-04-06 6 views
0

내가 지금 얼마 동안이 스크립트 http://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/를 사용하고 구글 날씨 API를 사용하는 데 문제가 있지만 이전이 오류를 가지고 :구글 날씨 API를 문제

Warning: simplexml_load_file() [function.simplexml-load-file]: //www.google.com/ig/api?weather=bermuda:2: parser error : Opening and ending tag mismatch: meta line 1 and HEAD in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]: 302 Moved in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]:^in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]: //www.google.com/ig/api?weather=bermuda:6: parser error : Opening and ending tag mismatch: HEAD line 1 and HTML in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]:^in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]: //www.google.com/ig/api?weather=bermuda:7: parser error : Premature end of data in tag HTML line 1 in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Warning: simplexml_load_file() [function.simplexml-load-file]:^in /home/webmx04/public_html/weather/widgetlive1.php on line 3

Fatal error: Call to a member function xpath() on a non-object in /home/webmx04/public_html/weather/widgetlive1.php on line 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> 

+0

태그가 일치하지 않는 소스를 참조하십시오. 부적절한 장소에서 태그가 닫히거나 닫히지 않는다는 것을 의미합니다. –

+0

답장을 보내 주셔서 감사합니다. 위의 코드로 불일치하는 것이 무엇을 의미합니까? 내가 잘못하고있는 것을 볼 수 있습니까? , http://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/의 데모가 잘 작동하는지 잘 모르겠지만 붙여 넣기를 복사하면됩니다. 그것은 내 호스팅에 그냥 오류가 – Brian

+0

그것은 자체가 해결 됐어 무슨 일이 있었는지 우둔 해요 – Brian

답변

1

분명히 구글이 소개 d Captcha를 날씨 API에 추가합니다. 그것은 하나, 둘 또는 세 번 작동하지만, 같은 서버에서 몇 가지 요청 후 Captcha를 재생하도록 요청합니다. 당신의 플러그인이 할 수없는 것.

나는이 문제를 해결할 방법을 모르고 있으므로 사용할 다른 날씨 API를 찾아야 할 것 같습니다. 내가 틀렸다면 제발 정정 해주세요. 도움이 될 것입니다.

Google 날씨의 캐싱 결과도 도움이 될 수 있습니다. 15 분 또는 30 분 안에 1 건의 요청을 받아 들일 수 있습니까?