Permalink
Browse files

+ gdeposylka.ru: rewrited in Perl using API

Requires API key (get one in your account settings).
Maybe adding trackcode feature will be added.
  • Loading branch information...
lexszero committed Dec 22, 2013
1 parent f03e8fb commit 3e73deb7d7bee172125a9b971acc0a915b430a80
Showing with 35 additions and 0 deletions.
  1. +35 −0 gdeposylka.ru/gdeposylka.pl
@@ -0,0 +1,35 @@
#!/usr/bin/perl
use strict;
use warnings;
use encoding 'utf8';
use feature 'switch';
use JSON;
use LWP::Simple;
use URI::Escape;
my $apikey = "PUT_NUMBERS_FROM_YOUR_ACCOUNT_HERE";
sub request {
my ($method, %args) = @_;
$args{'apikey'} = $apikey;
my ($k, @a);
foreach $k (keys %args) {
push @a, "$k=" . uri_escape($args{$k});
}
my $resp = get("http://ws.gdeposylka.ru/x1/$method/json?".join("&", @a)) or die;
return %{from_json($resp, {"utf8" => "1"})} or die;
}
my (%data, $k, %v);
given ($ARGV[0]) {
# TODO: add, detailed track info (anybody need this shit anyway?)
default {
%data = request("tracks.list", "area" => "main" );
%data = %{$data{tracks}};
foreach $k (keys %data) {
%v = %{$data{$k}};
print "$k ($v{description})\n";
print "\t" . localtime($v{last_date}) . ": $v{message}\n";
}
}
};

0 comments on commit 3e73deb

Please sign in to comment.