New project page available at Sourceforge. Please take a look for latest code.
I have just started developing a new library about sending free SMS via websites. I think it will look similar in structure to WWW::Search with many WWW::SMS::SomeGateway submodules. I read perlmod and perlmodlib but before finalizing the simple methods and writing documentation i'd like to have some advice from some higher level monks. Anybody is willing to help me out? I will send him the first scratch of my work licensed under GPL. Here is some code from SMS.pm:
And here is the sample for a submodule:#!/usr/bin/perl -w #Copyright (c) 2001 Giulio Motta. All rights reserved. #This program is free software; you can redistribute it and/or #modify it under the same terms as Perl itself. package WWW::SMS; use Carp (); $VERSION = '0.01'; sub new { my $class = shift; my $self; if (@_ == 4) { my ($intpref, $prefix, $telnum, $smstext) = @_; $self = bless { 'intpref' => $intpref, 'prefix' => $prefix, 'telnum' => $telnum, 'smstext' => $smstext }, $class; } else { $self = bless{}, $class; } } sub send_sms { my ($class, $sms, $gateway) = @_; my $gate = "${class}::${gateway}"; eval "use $gate qw(" . '%PREFIXES _send)'; Carp::croak("not such a gateway available: $gateway ($@)\n") i +f ($@); if (%PREFIXES) { ((warn "Prefix $sms->{prefix} not supported by $gatewa +y") && ret +urn 0) unless (exists $PREFIXES{$sms->{prefix}}); } return _send($sms); }
Sorry for the poor indentation :`(#!/usr/bin/perl -w package WWW::SMS::Vizzavi; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(); @EXPORT_OK = qw(%PREFIXES _send MAXLENGTH); %PREFIXES = map {$_, 1} qw(333 335 338 339 340 347 348 349 328 329 380 + 388 389); $VERSION = '1.00'; sub MAXLENGTH () {140} sub _send { my $self = shift; use HTTP::Request::Common qw(GET POST); use HTTP::Cookies; use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->agent('Mozilla/5.0'); $ua->cookie_jar(HTTP::Cookies->new( file => "lwpcookies.txt", autosave => 1)); $self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1) if (length($self->{smstext})>MAXLENGTH); $req = POST 'http://sms.vizzavi.it/global.asp', [ 'txtMsg' => $self->{smstext} ,'selPref' => $se +lf->{prefix}, 'TypeOpen' => '1' ,'txtTel' => $self->{telnum} + , 'Counter' => '' ]; $req->headers->referer('http://sms.vizzavi.it/freesms_conf.asp +'); print "1...\n"; $file = $ua->simple_request($req)->as_string; return 0 unless ($file =~ m'Messaggio\+accodato\+con\+successo +'s); $ua->cookie_jar->clear(); 1; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::SMS
by rrwo (Friar) on Oct 18, 2001 at 02:35 UTC | |
by giulienk (Curate) on Oct 18, 2001 at 10:46 UTC | |
by rrwo (Friar) on Oct 19, 2001 at 07:03 UTC | |
|
Re: WWW::SMS
by zuqif (Hermit) on Oct 17, 2001 at 17:23 UTC | |
by giulienk (Curate) on Oct 17, 2001 at 18:17 UTC | |
by zuqif (Hermit) on Oct 17, 2001 at 18:50 UTC | |
by giulienk (Curate) on Oct 17, 2001 at 19:14 UTC | |
|
Re: WWW::SMS
by seanbo (Chaplain) on Oct 16, 2001 at 22:05 UTC | |
|
Re: WWW::SMS
by BMaximus (Chaplain) on Oct 18, 2001 at 04:34 UTC |