Greetings folks..
While this isn’t a complete usage meter (as the title leads one to believe) it is a huge step in the right direction.
Basically reading the code below should make it fairly easy to understand the procedure for gathering information from Virgin Mobile’s usage system.
If I get time I’ll port it to javascript and pascal (for Delphi) – in the mean time I’m sure someone can use it…
#!/usr/bin/perl -w
use LWP;
use XML::Simple;
use Data::Dumper;
use strict;
# Configuration - Specify your username and password here
my $USERNAME = 'yourusername';
my $PASSWORD = 'yourpassword';
my $agent = LWP::UserAgent->new;
# Not sure if it works without cookies, wasn't going to try
$agent->cookie_jar({});
# Authenticate
my $xmlAuth = doPost( 'auth', [
action => 'authenticate',
password => $PASSWORD,
username => $USERNAME
] );
die "Authentication Failure\n" if ($xmlAuth->{authenticated} != 1);
print "Authenticated as: ", $xmlAuth->{username}[1], "\n";
# Get the customer ID (I don't know why we jump through so many hoops, but hey)
my $xmlCustID = doPost( 'service', [
action => 'get_customer_id',
username => $xmlAuth->{username}[1]
] );
die $xmlCustID->{error}, "\n" if ($xmlCustID->{error});
print "Customer ID: ", $xmlCustID->{customer_id}, "\n";
# Now get the list of services, this returns all services including email addresses.
my $xmlServices = doPost( 'service', [
action => 'get_services',
customer_id => $xmlCustID->{customer_id}
] );
print Dumper($xmlServices);
# Shortcut post method, saves code (c:
sub doPost {
my $page = shift;
my $data = shift;
my $response = $agent->post(
'http://mybroadbandusage.virginbroadband.com.au/cgi-bin/ajax/'.$page.'.cgi', $data
);
die "HTTP Error: ", $response->status_line unless $response->is_success;
return XMLin $response->content;
}