Skip to content

Instantly share code, notes, and snippets.

@dk
Last active August 30, 2019 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dk/069e880cb3146b3e35bf4929f8addb99 to your computer and use it in GitHub Desktop.
Save dk/069e880cb3146b3e35bf4929f8addb99 to your computer and use it in GitHub Desktop.
#!env perl
use strict;
use warnings;
use Net::Eboks;
use Getopt::Long;
my %opt = (
cpr => '',
activation => '',
pincode => '',
output => 'eboks.mbox',
help => 0,
);
my $version = 0.01;
sub usage
{
print <<USAGE;
$0
--cpr - CPR code, 0123456-7890
--activation - activation code
--pincode - PIN code
--output - output mail box ( $opt{output} )
--help
USAGE
exit 1;
}
GetOptions(\%opt,
"help|h",
"cpr|c=s",
"activation|a=s",
"pincode|p=s",
"output|o=s",
) or usage;
$opt{help} and usage();
sub fetch
{
my $key = shift;
return if length $opt{$key};
$|=1;
print "Enter $key code: ";
$opt{$key} = <STDIN>;
chomp $opt{$key};
print "\n";
}
fetch($_) for qw(cpr activation pincode);
$opt{cpr} =~ s/\-//g;
my $e = Net::Eboks->new(
cpr => $opt{cpr},
activation => $opt{activation},
password => $opt{pincode},
);
print "Logging in...\n";
my ($uname, $error) = $e->fetch_request($e->login)->wait;
die "error: $error\n" if defined $error;
print "Welcome, $uname\n";
print "Getting list of folders...\n";
my ($folders, $list, $msg);
($folders, $error) = $e->fetch_request( $e->xmlget("/mobile/1/xml.svc/en-gb/$e->{uid}/0/shares?listType=active") )->wait;
open F, ">shares.txt";
use Data::Dumper; print F Dumper( $folders);
die "error: $error\n" if defined $error;
close F;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment