12 # sms.pl MOBILE_NO "TEXT_MESSAGE"
14 # You need to set .smsrc file in the HOME directory and fill it like this:
18 # where LOGIN and PASSWORD are your credentials to orange.pl site
20 my $conf = new Config::General("$ENV{HOME}/.smsrc");
21 my %config = $conf->getall;
22 die "No login in config file. Stopped" unless $config{login};
23 die "No password in config file. Stopped" unless $config{password};
25 my $number = $ARGV[0];
26 my $message = $ARGV[1];
27 die "No recipient number entered. Stopped" unless $number;
28 die "No message entered. Stopped" unless $message;
30 my $mech = WWW::Mechanize->new;
31 $mech->get("http://orange.pl");
33 form_id => 'loginForm',
35 '/tp/core/profile/login/ProfileLoginFormHandler.value.login' => $config{login},
36 '/tp/core/profile/login/ProfileLoginFormHandler.value.password' => $config{password}
39 $mech->follow_link( text => 'Multi Box' );
40 $mech->follow_link( text => 'SMS' );
42 my $dom = Mojo::DOM->new;
43 $dom->parse($mech->content());
45 my $send_url = $dom->find('div[id="top-buttons"] a')->[1]->attr('href');
46 $mech->get($send_url);
48 # Using $mech->submit_form instead is not working, so don't change
50 $mech->form_name('sendSMS');
52 '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $number,
53 '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message,
57 $dom->parse($mech->content());
59 my $free_sms_left = $dom->find('div[id="syndication"] p span')->[1]->text;
61 print "Message has been sent. Free sms'es left: $free_sms_left\n";