The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::SMS - Send SMS messages to ANY device.

SYNOPSIS

Net::SMS is a global short text messaging service interface via the Internet. It brings you the first and only way to send SMS messages through one easy interface. SimpleWire has defined an XML SMS standard and will make numerous tools available for developer's use so that SMS technology can be better utilized. Currently, this interface supports more than just SMS enabled devices and can send messages to ANY protocol.

NOTE that SMS 2.00 is not backwards compatible with 1.00! Don't upgrade if your scripts are important!!

QUICK START

use Net::SMS;

# Create a new SMS object my $sms = Net::SMS->new();

# Setup the SMS message parameters $sms->msgCarrierID(7); $sms->msgPin("4152224444"); $sms->msgFrom("Demo"); $sms->msgCallback("3124445555"); $sms->msgText("Hello World from Simplewire!");

# Send the SMS message off $sms->msgSend();

# Check out what happened if ($sms->success) { print "Message was successfully sent via Simplewire!\n"; } else { print "Message was not successfully sent via Simplewire!\n"; print "Error Code: " . $sms->errorCode . "\n"; print "Error Description: " . $sms->errorDesc . "\n"; }

PREREQUISITES

The following packages are required in order to run or even install Net::SMS.

   * LWP::UserAgent >= 5.47
   * XML::DOM (libxml-enno) >= 1.02

DESCRIPTION

Net::SMS is the Perl interface to Simplewire's expanding messaging network. The module interacts with Simlewire's Remote Procedure Calls. The Remote Procedure Calls provide an XML API and the protocol is open to all developers. For futher support or questions, you should visit SimpleWire's website at www.simplewire.com. There you will find support and documentation including the white paper explaining the SimpleWire XML API.

SMS OVERVIEW

SMS stands for short-text messaging service. The current version of this module takes a minimalist approach to SMS, but upcoming versions plan to take full advantage of SMS.

A SMS message will require a minimum of 3 to 5 properties to be set within a request object. The first property, a PIN, is the Pager Identification Number. This is typically the phone number of the device you are trying to message. This number does not include a 1 before the area code and typically looks like 3135551212. The second property, a Service ID, is a proprietary service number assigned by Simplewire. The Carrier ID tells Simplewire where to route your message. For example, a Service ID of 7 sends a message to AT&T. The third property, the From field, is typically an optional field that is simply the sender's name. An example would be "Jack". The fourth property, the Callback field, is typically an optional field that is simply the sender's callback number. An example would be "3125551212". The fifth and last property is the Text field. This is not optional and is the alphanumeric message you wish to send. This just explains the basic properties, but be aware that MANY more properties and functions exist within the Net::SMS object.

Net::SMS OVERVIEW

See EXAMPLES section below to see working code.

The first step to using the Net::SMS module is to make sure LWP:UserAgent and XML::DOM are fully and correctly installed.

Basically, you instantiate a new Net::SMS object via $sms = new Net::SMS and this object handles communication with the simplewire servers.

EXAMPLES

All perl scripts or modules that use Net::SMS must include these lines before the code attempts to access any functions in the Net::SMS package.

    use Net::SMS

After properly including these two modules above, your code is ready to begin sending a message. The following code will construct a basic Net::SMS object and send off a message.

    use Net::SMS

    # Construct a new SMS object
    my $sms = Net::SMS->new();

    # Set the service id.  Check www.simplewire.com for a full listing
    # of the services that are supported.
    $sms->msgCarrierID(2);
    $sms->msgPin("1234567890");
    $sms->msgFrom("Jack Smith");
    $sms->msgCallback("9876543210");
    $sms->msgText("Hello World From Net::SMS");

    # Send the request off.
    $sms->msgSend();

    # Check out what happened.
    if ($sms->success) {
        print "Success!\n";
        print "Error Code: " . $sms->errorCode . "\n";
        print "Error Description: " . $sms->errorDesc . "\n";
        print "Your ticket number is: " . $sms->msgTicketID . "\n";
    } else {
        print "Error occurred!\n";
        print "Error Code: " . $sms->errorCode . "\n";
        print "Error Description: " . $sms->errorDesc . "\n";
    }

The second type of request supported in Net::SMS is a 'servicelist'. This request will fetch the service list from Simplewire and the associated service id's for each provider. This is useful for populating a <select> box for websites. The following code will grab the list and set two optional parameters so that only the information necessary for populating a <select> box is retrieved from Simplewire. The code will then print out some of the results in two different ways.

    use Net::SMS;

    my $sms = Net::SMS->new();

    # Send the request now
    $sms->carrierListSend();
    my @services = $sms->carrierList();

    # Check out what happened.
    if ($sms->success) {
        print "Success!\n";
        print "Error Code: " . $sms->errorCode . "\n";
        print "Error Description: " . $sms->errorDesc . "\n";
    } else {
        print "Error occurred!\n";
        print "Error Code: " . $sms->errorCode . "\n";
        print "Error Description: " . $sms->errorDesc . "\n";
    }

    foreach $ser (@services) {
        print $ser->{ID} . "\n";
    }

The third type of request supported in Net::SMS is a 'checkstatus'. This request will fetch the status of a previously sent message. Every 'sendpage' request that passes most error checking will be assigned a ticket. It is this ticket that needs to be sent thru during a 'checkstatus' request. The following code example will check the status of a previously sent message.

    use Net::SMS;

    # Note that you will have had to do a sendpage and get a TICKET_ID
    # back for you to check with.

    my $sms = Net::SMS->new();


    # Set the ticket id to check.
    $sms->msgTicketID("XXXXX-3MTWX-28UM0-8H1L7");

    # Request it.
    $sms->msgStatusSend();

    # Check out what happened.
    if ($sms->success) {
        print "Success!\n";
        print "Error Code: " . $sms->errorCode . "\n";
        print "Error Description: " . $sms->errorDesc . "\n";
    } else {
        print "Error occurred!\n";
        print "Error Code: " . $sms->errorCode . "\n";
        print "Error Description: " . $sms->errorDesc . "\n";
    }

Support can also be obtained by emailing techsupport@simplewire.com.

SEE ALSO

www.simplewire.com on the web.

AUTHOR

Simplewire <techsupport@simplewire.com> www.simplewire.com

COPYRIGHT

Copyright (c) 2001 Simplewire. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.