2020-07-22 10:29:32 -06:00
#!/usr/bin/perl -w
use strict;
use warnings;
use JSON;
2023-02-10 10:54:10 -07:00
my $APIKEY = "e1f10a1e78da46f5b10a1e78da96f525" ;
2023-02-10 11:21:34 -07:00
my $StationID = ( $ARGV [ 0] or "KUTRIVER63" ) ;
2020-07-22 10:29:32 -06:00
my $Units = "m" ; # e = imperial, m = metric
2023-02-10 10:54:10 -07:00
my $info = ` curl -sm 1 " https://api.weather.com/v2/pws/observations/current?apiKey= $APIKEY &stationId= $StationID &numericPrecision=decimal&format=json&units= $Units " ` or die "Error" ;
2020-07-22 10:29:32 -06:00
my $json = decode_json $info or die "Error" ;
my $loc = %{ $json } { "observations" } ->[ 0] ->{ "stationID" } ;
my $temp = %{ $json } { "observations" } ->[ 0] ->{ "metric" } ->{ "temp" } ;
my $windS = %{ $json } { "observations" } ->[ 0] ->{ "metric" } ->{ "windSpeed" } ;
my $windD = %{ $json } { "observations" } ->[ 0] ->{ "winddir" } ;
2023-02-10 11:21:34 -07:00
print "?:" .$temp .":" .$windS .":" .$windD .":(WU)" .$loc ;