Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8368351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:22:07+00:00 2026-06-09T13:22:07+00:00

I have created an Element for my project which loads the Google Weather API.

  • 0

I have created an Element for my project which loads the Google Weather API. Locally it works perfectly. The problem appeared when I uploaded it and when I gave it to a friend of mine to try it.

The code for the element is the following one

<?php
Configure::write('debug', 2);

$xml = simplexml_load_file('http://www.google.com/ig/api?weather=name_city');
$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>
<h1><?= print $information[0]->city['data']; ?></h1>
<h2>Today's weather</h2>
<div class="weather">
<?php $icon_today = (string) $current[0]->condition['data'];?>

<?php echo $this->Html->image('tick/'.$icon_today.'.png');?>
        <span class="condition">
        <?= $current[0]->temp_c['data'] ?>&deg; C,

        </span>
 </div>
<h2>Forecast</h2>
    <? foreach ($forecast_list as $forecast) : ?>
    <div class="weather">
    <?php $icon = (string) $forecast->condition['data'];?>
      <?php echo $this->Html->image('tick/'.$icon.'.png',array('width' => '45'));?>

        <div><?= $forecast->day_of_week['data']; ?></div>
        <span class="condition">
        <?php
        $low = (int) $forecast->low['data'];
        $high = (int) $forecast->high['data'];
        $low_celsius = (int) (($low - 32) * (5/9));
        $high_celsius = (int)(($high - 32) * (5/9));
        ?>
            <?= $low_celsius ?>&deg; C - <?= $high_celsius ?>&deg; C,
            <?= $forecast->condition['data'] ?>
        </span>
 </div>
<? endforeach ?>
</body>
</html>

When I uploaded it I got these messages

Warning (2): simplexml_load_file() [function.simplexml-load-file]:     
http://www.google.com/ig/api?weather=name_city: parser error : Document is empty     
[APP/View/Elements/weather.ctp, line 5]
Warning (2): simplexml_load_file() [function.simplexml-load-file]:   
[APP/View/Elements/weather.ctp, line 5]
Warning (2): simplexml_load_file() [function.simplexml-load-file]: ^ 
[APP/View/Elements/weather.ctp, line 5]
Warning (2): simplexml_load_file() [function.simplexml-load-file]: 
http://www.google.com/ig/api?weather=name_city:1: parser error : Start tag 
expected, '<' not found [APP/View/Elements/weather.ctp, line 5]
Warning (2): simplexml_load_file() [function.simplexml-load-file]:  
[APP/View/Elements/weather.ctp, line 5]
Warning (2): simplexml_load_file() [function.simplexml-load-file]: ^ 
[APP/View/Elements/weather.ctp, line 5]
Fatal error: Call to a member function xpath() on a non-object in 
/home/wwwsite/public_html/testing/app/View/Elements/weather.ctp on line 6

name_city has a real value. When I tried it on another computer there where other types of error ($forecast->day_of_week[‘data’] for example was not recognized as a valid variable). It seems that the online version is not able to receive data from Google Weather so the result is empty. Could anyone please tell me what to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:22:09+00:00Added an answer on June 9, 2026 at 1:22 pm

    There is currently an intermittent 403 Forbidden response to the Google Weather API that you are using. See Google Weather API 403 Error

    The 403 response may be causing the empty document that you see in the first line of the results. Rerun the code again now both locally and on the server and see if the problem is intermittent.

    The reason for the intermittent 403 response is not known but has been a problem since the 7th of August 2012 which is the time that you posted this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a basic shape in HTML canvas element which works fine. The
I've created a form with code and I have a big problem. Every element
i have created a slideshow, using jquery which has fade effect, the problem with
I have a responsive layout and I've created a fading panels animated element with
I have problems setting the focus on an input element that has been created
In my mvc 3 project I have a form which contains a list of
I have a project which i need to build in two different configurations. One
I have a class library that I created using the Class Library project template.
I've looked over the web and have found loads of answers none of which
I have created a class library that should connect to a WCF endpoint project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.