最近pchome 的sms簡訊系統改版,搞不定它,所以拿了網路上前人所寫的 hinet adsl sms sender 來改一改,湊合著用,以下是程式碼
#!/usr/bin/perl
use WWW::Mechanize;
use strict;
my $msg = < stdin >;
chomp $msg ;
&amp;sendsms("Hinet HN 號碼", "密碼", "手機號碼", $msg);
sub sendsms {
my ($username, $password, $receiver, $msg) = @_;
my $number = 0;
my $agent = WWW::Mechanize->new(); $agent->get("<a href="http://hiair.hinet.net/hweb/hiairpost_new.jsp">http://hiair.hinet.net/hweb/hiairpost_new.jsp</a>");
$agent->form("form1");
foreach (split(/[ ,]+/, $receiver))
{
$agent->field("tel", $_, ++$number);
}
$agent->field("add_name", "0");
$agent->field("message", $msg);
$agent->submit();
$agent->form("loginform"); $agent->submit();
$agent->form("AuthScreen");
$agent->field("aa-uid", $username);
$agent->field("aa-passwd", $password);
$agent->submit();
foreach (split(/\r\n/, $agent->content()))
{
next unless (/window.location.replace/i);
$_ =~ /window.location.replace\('(.+)'\)/i;
my $newurl = $1;
$agent->get($newurl);
# print($newurl);
last;
}
#print($newurl);# print($agent->content());

}

創作者介紹

Ben 的 IT 學習之不歸路網誌

ben88168 發表在 痞客邦 PIXNET 留言(0) 人氣()