Net::SMS::O2 - a module to send SMS messages using the O2 web2sms gateway (http://www.o2.co.uk/).
my $sms = Net::SMS::O2->new( autotruncate => 1, username => 'yourname', password => 'yourpassword', recipient => 07713123456, subject => 'a test', message => 'a test message', ); $sms->verbose( 1 ); $sms->message( 'a different message' ); print "sending message to mobile number ", $sms->recipient(); $sms->send_sms();
A perl module to send SMS messages, using the O2 web2sms gateway. This module will only work with mobile phone numbers that have been registered with O2 (http://www.o2.co.uk/) and uses form submission to a URL that may be subject to change. The O2 service is currently only available to UK mobile phone users.
There is a maximum length for SMS subject + message (115 for O2). If the sum of subject and message lengths exceed this, the behaviour of the Net::SMS::O2 objects depends on the value of the 'autotruncate' argument to the constructor. If this is a true value, then the subject / message will be truncated to 115 characters. If false, the object will throw an exception (die). If you set notruncate to 1, then the module won't check the message length, and you are on your own!
Pragma: no-cache Via: 1.0 www3 (HTTP::Proxy/0.07) Accept: application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* Accept-Language: en-gb Host: sendtxt.o2.co.uk Referer: http://sendtxt.o2.co.uk/webOriginate/action/viewHomePage User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Q312461) Content-Length: 128 Content-Type: application/x-www-form-urlencoded Cookie: anonP3=Ave; username=awrigley; QE3=UmFuZG9tSVYa8uqjNRdebN1ccKhWTkav; rAT=qCsxqa-8q_UNEMeYxegp6dxlG3Pm_mPi; rID=44413; JSESSIONID=2flHC7azFO4dDFoUUdkrm5QD4x8ocdbpgpVzGgVVVouWlL24iKvO!-1057879407
The constructor for Net::SMS::O2 takes the following arguments as hash values (see SYNOPSIS):
O2 has a upper limit on the length of the subject + message (115). If autotruncate is true, subject and message are truncated to 115 if the sum of their lengths exceeds 115. The heuristic for this is simply to treat subject and message as a string and truncate it (i.e. if length(subject) >= 115 then message is truncated to 0. Thanks to Mark Zealey <firstname.lastname@example.org> for this suggestion. The default for this is false.
Of course, if you don't believe the O2 web interface about maximum character length, then you can set this option.
The O2 username for the user (assuming that the user is already registered at http://www.o2.co.uk/.
The O2 password for the user (assuming that the user is already registered at http://www.o2.co.uk/.
Mobile number for the intended SMS recipient.
SMS message subject.
SMS message body.
If true, various soothing messages are sent to STDERR. Defaults to false.
All of the constructor arguments can be got / set using accessor methods. E.g.:
$old_message = $self->message; $self->message( $new_message );
This method is invoked to actually send the SMS message that corresponds to the constructor arguments.
Bugs can be submitted to the CPAN RT bug tracker either via email (email@example.com) or web http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-SMS-O2. There is also a sourceforge project at http://sourceforge.net/projects/net-sms-web/.
Ave Wrigley <Ave.Wrigley@itn.co.uk>
Copyright (c) 2001 Ave Wrigley. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.