#!/usr/bin/perl use strict; use warnings; use constant TO => '1234567890'; use constant FROM => 'xxxx@xxxx.com'; use constant SUBJECT => 'xxxx'; use constant CALLBACK => '1234567890'; use constant PRIORITY => 1; use constant MAX_CHARS => 160; use constant PAGE => 'http://www.vtext.com/customer_site/jsp/disclaimer.jsp'; use constant AGENT => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041118 ' . 'Firefox/1.0'; use constant MESSAGES => [ # Each message must be <= 160 chars (SMS limit) 'Run away', ]; sub send_sms { my $msg = shift; use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->add_header(Referer => 'http://www.vtext.com/customer_site/jsp/messaging_lo.jsp'); $mech->get( PAGE ); $mech->submit_form( form_name => 'message_form', button => 'disclaimer_submit', x => 10, y => 15, fields => { 'trackResponses' => 'No', 'DOMAIN_NAME' => '@vtext.com', 'min' => TO, 'text' => $msg, 'subject' => SUBJECT, 'sender' => FROM, 'callback' => CALLBACK, 'type' => PRIORITY, }, ); return $mech->success(); } { use Apache::RequestUtil; my $r = Apache->request; my %in = $r->args(); my $msg_num = $in{emg} || 0; my $res = send_sms( substr( MESSAGES->[$msg_num], 0, 160 ) ) or die "Couldn't send message\n"; $r->content_type( 'text/plain' ); $r->print( MESSAGES->[$msg_num] ); }