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 => 'SMS');
41 my $dom = Mojo::DOM->new;
42 $dom->parse($mech->content());
44 my $send_url = $dom->find('div[id="top-buttons"] a')->[1]->attrs('href');
45 $mech->get($send_url);
47 # Using $mech->submit_form instead is not working, so don't change
49 $mech->form_name('sendSMS');
51 '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $number,
52 '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message,
56 $dom->parse($mech->content());
58 my $free_sms_left = $dom->find('div[id="syndication"] p span')->[1]->text;
60 print "Message has been sent. Free sms'es left: $free_sms_left\n";