logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 07-24-2010, 02:45 PM   #1
cocoonfx
cocoonfx's Avatar
 
Join Date: Nov 2006
Location: Tamworth,UK
Posts: 576
Default Weather widgets

Hi Chaps


I am trying to find a weather widget which can be resizable. Ideally a widget which is like 60 x 60 pxs as I don't have much space.

Any ideas?
cocoonfx is offline   Reply With Quote
Old 07-27-2010, 10:01 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

why not write your own using googles weather API

Just throw a city at it

http://www.google.com/ig/api?weather...stle+upon+tyne

just need to parse the xml response
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 07-27-2010, 03:04 PM   #3
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

Had some time on my hands (quite rare these days)

here is a little parser I knocked up which pulls out the icon image path from the google weather XML response

you can either replicate the path structure and use your own images or you could use a switch to remap the paths altogether
PHP Code:
<?php

//Name of your place
$place="newcastle+upon+tyne";

//Initialize CURL
$curl curl_init();

$timeout 0;

//Set CURL options
curl_setopt ($curlCURLOPT_URL'http://www.google.com/ig/api?weather='.$place.'&hl=en');
curl_setopt ($curlCURLOPT_RETURNTRANSFER1);
curl_setopt ($curlCURLOPT_CONNECTTIMEOUT$timeout);

$xml_str=curl_exec($curl);

//close CURL 
curl_close($curl);

// Parse the XML response
$xml = new SimplexmlElement($xml_str);

$icons = array();

        foreach(
$xml->weather as $item) {

                foreach(
$item->forecast_conditions as $new) {

                    
$icons[] = $new->icon['data'];
                }
        }

        
///////////////////////////////
        // output array of image paths (debug use only)
        
echo "<pre>";
        
print_r($icons);
        echo 
"</pre>";
        
///////////////////////////////
        
?>
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 07-27-2010, 04:23 PM   #4
Corrosive
Corrosive's Avatar
 
Join Date: Feb 2008
Location: Bristol, England
Posts: 7,103
Default

Could you use the Google geolocator to output the user's location and feed it into $place?
Corrosive is offline   Reply With Quote
Old 07-27-2010, 07:15 PM   #5
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

Yes of course

I have used this on a site before

http://www.maxmind.com/app/city

Never looked at the google solution
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 07-27-2010, 07:26 PM   #6
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

A nice set of icons/sprite you could use with it... here
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com