diff options
Diffstat (limited to 'forecast.pl')
-rw-r--r-- | forecast.pl | 27 |
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; |