Simple, Beautiful, SMooVo.

Google Weather Api

How to use Google's Weather API in your website (PHP).

There are many reasons to add weather API to your website. 124,000,000 search queries for "weather" are processed each month, and sometimes it relates to your business. How can you add it? How to find the one that will fit your desired area? Is there a free tool online to build it?

The answer for all this questions is Google's weather API. Google has an API that processed information about weather temperatures and conditions for 5 days, the recent and 4 days forward. Like all others API that Google developed, it's free.

Basically you need to be knowledgeable with HTML, CSS and PHP. The code contains the information puller (PHP), and the designer code (HTML & CSS).

Live Example

New-York City Weather

weather
Now
74° F,Clear
weather
Sat
57° F - 77° F, Clear
weather
Sun
59° F - 77° F, Mostly Sunny
weather
Mon
61° F - 70° F, Chance of Showers
weather
Tue
59° F - 75° F, Fog

How To?

This API is XML file response from Google's server. We request this XML file for our specific area first.

<?php
    $xml = simplexml_load_file('http://www.google.com/ig/api?weather=new-york');
    $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");
?>
The first line gets the XML file with "new-york" weather information. The other lines is for the variables to be ordered.
Now we can start build our HTML/PHP content.
<h1>New-York City Weather</h1>
    <div class="weather">
        <img src="<?php echo 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather" />
        <div class="condition"><strong>Today</strong><br />
            <?php echo $current[0]->temp_f['data'] ?>° F,<?php echo $current[0]->condition['data'] ?>
        </div>
    </div>

    <?php foreach ($forecast_list as $forecast) { ?>

        <div class="weather">
            <img src="<?php echo 'http://www.google.com' . $forecast->icon['data']?>" alt="weather" />
            <div class="condition">
                <strong><?php echo $forecast->day_of_week['data']; ?></strong><br />
                    <?php echo $forecast->low['data'] ?>° F - <?php echo $forecast->high['data'] ?>° F,
                <?php echo $forecast->condition['data'] ?>
            </div>
        </div>
    <?php } ?>
You want it to be nice, right? CSS...
.weather {width:245px; height:40px; background:#d7d7d7; padding:2px; margin-bottom:2px;}
.weather img {float:left;}
.weather .condition {width:200px; height:40px; float:right; text-align:left;}
That's it, you can view the example again.

News

CMS
Our new management system designed to provide 100% tracking and managing stores online. The new system built by the highest technology, and this provides more power by less size and more flexibility by less pages.
iPhone Apps
We start our new firm in New-York of iPhone™, iPod™ & iPad™ Apps development. We are in process of 5 new apps that never seen before.

New projects

Imani Chocolatiers LLC is a new growing business in the candy and gifts industry. This website has been designed and programmed by SMooVo for ecommerce use, and it is using our new CMS for shopping carts, orders management and products management.

Technology used: HTML5, CSS, JavaScript, jQuery, PHP, MySQL, Photoshop CS4, Flash CS4, ActionScript3.0.
This website been made for professional locksmith company in NY. We are managing their website and their SEO. It is made with template.

New Testimonials

"It is scary to invest money while you trying to grow, but with Smoovo it's a different story. From the beginning they helped us to understand and believe in our goal, and they give us the idea behind the web design."
"I'm so happy with their work; they have put my business on line. I have more customers and I'm keeping get compliments about my online business."
"Even though I am in Australia and Smoovo is in the USA, my project developed by Smoovo, could not of gone better. Nothing was a problem and Smoovo's business manner was impeccable. If you need website development I highly recommend the guys at Smoovo."
"smoovo is by far the most reliant and responsive team I have ever worked with. They go far and beyond your project expectations and have so much knowledge and input into your project that it's as if they are your partners in business. It's always a pleasure working with them and they are very reasonably priced."