Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Wed Jul 17, 2019 9:43 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: Fri Apr 10, 2009 5:44 pm 
Offline
User avatar

Joined: Tue Sep 11, 2007 10:56 am
Posts: 31
Ok. I have most of it done..

The problem is Wind Speeds. I don't know where the heck it's getting the wind speeds, but they are not correct. Sometimes they are WAY off.

How do you dump the variables to the screen?


Top
 Profile  
 
 Post subject: Re: AccuWeather script & templates
PostPosted: Wed Feb 16, 2011 2:28 pm 
Offline

Joined: Fri Jan 16, 2009 3:52 pm
Posts: 7
I did some reworking of the accuweather.php script. Okay, I rewrote it. For folks in the USA, one can simply change the zip code in the URL to your location. If you prefer metric instead of English measurements, change the metric=0 to metric=1 in the URL.

Hope this helps!
Code:
<?php
$file = "http://forecastfox.accuweather.com/adcbin/forecastfox/weather_data.asp?location=20001&metric=0&partner=forecastfox";

$uvindex = array( "Low" => 2, "Moderate" => 4, "High" => 6.5, "Very High" => 9, "Extreme" => 11 );

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "cData");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);

$xml = simplexml_load_string($result);

// Dump the output
//print_r($xml->currentconditions);

$pressure = $xml->currentconditions->pressure;
$temperature = $xml->currentconditions->temperature;
$realfeel = $xml->currentconditions->realfeel;
$humidity = rtrim($xml->currentconditions->humidity, '%');
$weathericon = $xml->currentconditions->weathericon;
$windgusts = $xml->currentconditions->windgusts;
$windspeed = $xml->currentconditions->windspeed;
$visibility = $xml->currentconditions->visibility;
$precip = $xml->currentconditions->precip;
$uvi = $uvindex[trim($xml->currentconditions->uvindex)];

echo "weathericon:".$weathericon." temperature:".$temperature." humidity:".$humidity." windgusts:".$windgusts." windspeed:".$windspeed." visibility:".$visibility." realfeel:".$realfeel." precip:".$precip." uvindex:".$uvi." pressure:".$pressure;

?>



Top
 Profile  
 
 Post subject: Re: AccuWeather script & templates
PostPosted: Sun Feb 20, 2011 3:22 am 
Offline

Joined: Sun Feb 20, 2011 3:19 am
Posts: 1
Hello everybody!

I wonder what i have to do to extract from XML the dorescast (<day number="1"></day>, <day number="2"></day>) etc. Any ideea?

Thanks.


Top
 Profile  
 
 Post subject: Re: AccuWeather script & templates
PostPosted: Sun Jul 01, 2012 9:23 am 
Offline

Joined: Wed Mar 30, 2011 2:13 am
Posts: 11
It is also possible to find location with geo coordinates:
1) lets say: monaco (http://itouchmap.com/latlong.html) -> 43.7 / 7.4
2) in php script from above modify
Code:
<?php
$file = "http://thale.accu-weather.com/widget/thale/weather-data.asp?slat=43.7&slon=7.4&metric=1";

3) $ php ./accwthr.php
Code:
php ./accwthr.php
weathericon:01 temperature:27 humidity:73 windgusts:9 windspeed:9 visibility:16 realfeel:32 precip:0.0 uvindex:4 pressure:101


Attachments:
monaco.png
monaco.png [ 143.17 KiB | Viewed 2536 times ]
Top
 Profile  
 
 Post subject: Re: AccuWeather script & templates
PostPosted: Wed Jun 17, 2015 7:05 pm 
Offline

Joined: Wed Jun 17, 2015 6:56 pm
Posts: 4
I used the following website to get my location http://pastebin.com/dbtemx5F to get me http://forecastfox.accuweather.com/adcbin/forecastfox/weather_data.asp?location=AFR|ZA|SF006|BELFAST&metric=1&partner=forecastfox

and used this script to get me the details

Code:
<?php
$file = "http://forecastfox.accuweather.com/adcbin/forecastfox/weather_data.asp?location=AFR|ZA|SF006|BELFAST&metric=1&partner=forecastfox";

$uvindex = array( "Low" => 2, "Moderate" => 4, "High" => 6.5, "Very High" => 9, "Extreme" => 11 );

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "cData");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);

$xml = simplexml_load_string($result);

// Dump the output
//print_r($xml->currentconditions);

$pressure = $xml->currentconditions->pressure;
$temperature = $xml->currentconditions->temperature;
$realfeel = $xml->currentconditions->realfeel;
$humidity = rtrim($xml->currentconditions->humidity, '%');
$weathericon = $xml->currentconditions->weathericon;
$windgusts = $xml->currentconditions->windgusts;
$windspeed = $xml->currentconditions->windspeed;
$visibility = $xml->currentconditions->visibility;
$precip = $xml->currentconditions->precip;
$uvi = $uvindex[trim($xml->currentconditions->uvindex)];

echo "weathericon:".$weathericon." temperature:".$temperature." humidity:".$humidity." windgusts:".$windgusts." windspeed:".$windspeed." visibility:".$visibility." realfeel:".$realfeel." precip:".$precip." uvindex:".$uvi." pressure:".$pressure;


Top
 Profile  
 
 Post subject: Re: AccuWeather script & templates
PostPosted: Sat Jul 11, 2015 8:23 pm 
Offline

Joined: Sat Jul 11, 2015 2:26 pm
Posts: 7
This script works great. But for the location, simply using a US ZIP code in the URL (?location=) worked for me. Thanks.

jckruger wrote:
I used the following website to get my location http://pastebin.com/dbtemx5F to get me http://forecastfox.accuweather.com/adcbin/forecastfox/weather_data.asp?location=AFR|ZA|SF006|BELFAST&metric=1&partner=forecastfox

and used this script to get me the details

Code:
<?php
$file = "http://forecastfox.accuweather.com/adcbin/forecastfox/weather_data.asp?location=AFR|ZA|SF006|BELFAST&metric=1&partner=forecastfox";

$uvindex = array( "Low" => 2, "Moderate" => 4, "High" => 6.5, "Very High" => 9, "Extreme" => 11 );

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "cData");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);

$xml = simplexml_load_string($result);

// Dump the output
//print_r($xml->currentconditions);

$pressure = $xml->currentconditions->pressure;
$temperature = $xml->currentconditions->temperature;
$realfeel = $xml->currentconditions->realfeel;
$humidity = rtrim($xml->currentconditions->humidity, '%');
$weathericon = $xml->currentconditions->weathericon;
$windgusts = $xml->currentconditions->windgusts;
$windspeed = $xml->currentconditions->windspeed;
$visibility = $xml->currentconditions->visibility;
$precip = $xml->currentconditions->precip;
$uvi = $uvindex[trim($xml->currentconditions->uvindex)];

echo "weathericon:".$weathericon." temperature:".$temperature." humidity:".$humidity." windgusts:".$windgusts." windspeed:".$windspeed." visibility:".$visibility." realfeel:".$realfeel." precip:".$precip." uvindex:".$uvi." pressure:".$pressure;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google Adsense [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group