Revision 37 (by dpavlin, 2004/04/28 10:20:50) use WWW::Mechanize to fill provider's form and send sms
#!/usr/bin/perl -w

use strict;
use WWW::Mechanize;
use Data::Dumper;

my $mech = WWW::Mechanize->new();

my $args = join(" ",@ARGV);

$args =~ s/^0/+385/;

my ($prefix,$number,$message);
if ($args =~ m/(\+385\d\d)(\d+)\s+(.+)/) {
	($prefix,$number,$message) = ($1,$2,$3);
} else {
	die "can't parse '$args' into number and message!";
}

my $url = 'http://www.vip.hr/sp/d_sendSMS?';
$mech->get( $url );

$mech->submit_form(
	form_name => 'isplogform',
	fields		=> {
		SMSusername	=> 'login',
		SMSpassword	=> 'password',
	},
	button		=> 'SMSsubmit'
);


sub dump_forms {
    my $mech = shift;

    for my $form ( $mech->forms() ) {
	print $form->dump;
	print "\n";
    }
}

$mech->submit_form(
	form_name => 'smsform',
	fields		=> {
		netpref => $prefix,
		phoneno => $number,
		mess	=> $message
	}
);

dump_forms($mech);