Net-SMS-Web
view release on metacpan or search on metacpan
#------------------------------------------------------------------------------
#
# Net::SMS::Web::Action utility module
#
#------------------------------------------------------------------------------
package Net::SMS::Web::Action;
use Class::Struct;
struct(
'Net::SMS::Web::Action' => {
url => '$',
method => '$',
agent => '$',
params => '%',
}
);
package Net::SMS::Web;
$VERSION = '0.015';
use strict;
use warnings;
#------------------------------------------------------------------------------
#
# Standard pragmas
#
#------------------------------------------------------------------------------
use LWP::UserAgent;
use CGI::Enurl;
use CGI::Lite;
use URI;
#------------------------------------------------------------------------------
#
# POD
#
#------------------------------------------------------------------------------
=head1 NAME
Net::SMS::Web - a generic module for sending SMS messages using web2sms
gateways (e.g. L<http://www.mtnsms.com/> or L<http://www.o2.co.uk/>).
=head1 DESCRIPTION
A perl module to send SMS messages, using web2sms gateways. This module
should be subclassed for a particular gateway (see L<Net::SMS::O2> or
L<Net::SMS::Mtnsms>).
When you subclass this class, you need to make a series of calls to the
L<action> method, passing a L<Net::SMS::Web::Action> object which should
correspond to the web form acions that are required to send an SMS message via
the web gateway in question.
The HTTP requests are sent using the LWP::UserAgent module. If you are using a
proxy, you may need to set the HTTP_PROXY environment variable for this to
work (see L<LWP::UserAgent>).
=cut
#------------------------------------------------------------------------------
#
# Package globals
#
#------------------------------------------------------------------------------
use vars qw( $DEFAULT_AGENT );
$DEFAULT_AGENT = 'Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)';
#------------------------------------------------------------------------------
#
# More POD ...
#
#------------------------------------------------------------------------------
=head1 CONSTRUCTOR
The constructor of this class can be overridden in a subclass as follows:
sub new
{
my $class = shift;
my $self = $class->SUPER::new( @_ );
$self->_init( @_ );
return $self;
}
=cut
sub new
{
my $class = shift;
my $self = bless {}, $class;
$self->{COOKIES} = {};
return $self;
}
sub _get_cookies
{
my $self = shift;
my $response = shift;
for ( grep s{;.*}{}, $response->header( 'Set-Cookie' ) )
{
if ( /^(.*?)=(.*)$/ )
{
$self->{COOKIES}{$1} = $2;
}
}
}
#------------------------------------------------------------------------------
#
# More POD ...
#
( run in 2.393 seconds using v1.01-cache-2.11-cpan-71847e10f99 )