You must make sure that these two setting in your PHP.INI file are set as follows:
allow_url_include = On
allow_url_fopen = On
You must also create a User account on geonames.org to be able to use the system to retrieve the weather station data (you might have noticed that yowindow uses geonameIds)
Then just replace the variables at the top:
google latitude User ID.
geoname ID
the flash vars as is seen in your current HTML for the size and whatever.
Call this PHP instead of writing the whole <param name="flashvars"........>
You'll still need all the other stuff in your oringal HTML, the DIVs and other PARAMs,
You can see it working on my site,http://www.talesfromthesaddle.com but the beauty is dragging your location on google latitude to all over the world and seeing the weather and locations change!
The time shown in Yowindow, on my computer at least, is not quite up to speed....maybe someone can point out my numerous errors.
Code: Select all
<?PHP
header('Content-Type: text/plain');
// VARIABLES, SET THESE AS NEEDED
$googleuserId = 'INSERT YOUR GOOGLE LATITUDE ID NUMBER';
$geonamesid= 'INSERT YOUR GEONAMES.ORG ID';
$flashvars= '&landscape=airport&time_format=24&us=uk&background=#666666&mini_momentBar=false©right_bar=false"><a href="http://yowindow.com/weatherwidget.php" style="width: 180px; height: 140px; display: block; text-indent: -50000px; font-size: 0px; background: #DDF url("http://yowindow.com/img/logo") no-repeat scroll 50% 50%">';
if ( $_GET['user'] ) {
if ( is_numeric( $_GET['user'] ) )
$googleuserId = $_GET['user'];
else
exit('This isn\'t a valid user id.');
}
$url = 'http://www.google.com/latitude/apps/badge/api?user='.$googleuserId.'&type=json';
// We get the content
$content = file_get_contents( $url );
// We convert the JSON to an object
$json = json_decode( $content );
$coord = $json->features[0]->geometry->coordinates;
$timeStamp = $json->features[0]->properties->timeStamp;
if ( ! $coord )
exit('This user doesn\'t exist.');
$date = date( 'Y-m-d H:i', $timeStamp );
$lat = $coord[1];
$lon = $coord[0];
// loop through our records to find weather station
$sXML = new SimpleXMLElement('http://api.geonames.org/findNearByWeather?lat='.$lat.'&lng='.$lon.'&username='.$geonamesid.'&style=short&maxRows=1', NULL, TRUE);
foreach($sXML as $geo)
{
$ICAO=$geo->ICAO;
$placename= $geo->stationName;
}
echo '<param name="flashvars" value="current_weather_icao='.$ICAO.'&location_name='.$placename.'&moment=';
//To Find Timezone
$sXML2 = new SimpleXMLElement('http://api.geonames.org/timezone?lat='.$lat.'&lng='.$lon.'&username='.$geonamesid.'&style=short&maxRows=1', NULL, TRUE);
foreach($sXML2 as $loop) // loop through our records
{
$timestamp=$loop->time;
$time=substr($timestamp, -5);
$date= substr(trim($timestamp), 0,10);
$offset = $loop->gmtOffset;
}
echo $date.'T'.$time.':00Z'.$offset.$flashvars;
?>