summaryrefslogtreecommitdiff
path: root/forecast.pl
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2013-05-16 21:01:28 +0100
committerdakkar <dakkar@thenautilus.net>2013-05-16 21:01:28 +0100
commitfa77e6c1b2eb526ab79a708ed8d04824c28f7445 (patch)
tree9275b386352ee040e1031eb3e813ac3e5adeb1bf /forecast.pl
parentforecast call options (diff)
downloadHomePanel-fa77e6c1b2eb526ab79a708ed8d04824c28f7445.tar.gz
HomePanel-fa77e6c1b2eb526ab79a708ed8d04824c28f7445.tar.bz2
HomePanel-fa77e6c1b2eb526ab79a708ed8d04824c28f7445.zip
modularise forceast client
Diffstat (limited to 'forecast.pl')
-rw-r--r--forecast.pl27
1 files changed, 9 insertions, 18 deletions
diff --git a/forecast.pl b/forecast.pl
index a3dd7d6..5d78906 100644
--- a/forecast.pl
+++ b/forecast.pl
@@ -2,30 +2,21 @@
use strict;
use warnings;
use 5.014;
-use LWP::Simple;
-use URI;
+use WebService::ForecastIo;
use JSON;
use Data::Printer;
my $key=$ARGV[0];
-my $base = URI->new('https://api.forecast.io/forecast');
-
-sub URI::path_segments_push {
- my ($uri,@segments) = @_;
- $uri->path_segments($uri->path_segments,@segments);
-}
-
-# home
-$base->path_segments_push(
- $key,"51.54,-0.37",
-);
-$base->query_form({
- units => 'si',
- exclude => 'minutely,flags',
+my $fio = WebService::ForecastIo->new({
+ api_key => $key,
});
-my $content = get($base);
+my $response = $fio->request({
+ latitude => 51.54,
+ longitude => -0.37,
+ exclude => ['minutely','flags'],
+});
-my $output = decode_json($content);
+my $output = decode_json($response);
p $output;