Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Here it is tarted up a bit. Semi-tested. Let me know if the license is not appropriate. Refs: strictures, LWP::UserAgent, URI, Getopt::Long, and Pod::Usage.

#!/usr/bin/env perl use strictures; use LWP::UserAgent; use URI; use Getopt::Long; use Pod::Usage; GetOptions( help => \my $help, "host=s" => \my $host, "port=i" => \my $port, "user=s" => \my $user, "password=s" => \my $password, "recipient=s" => \my $recipient, "message=s" => \my $message, ); pod2usage( -verbose => 2 ) if $help; $host ||= "127.0.0.1"; $port ||= 9501; $user ||= $ENV{OZEKI_NG_SMS_USER}; $password ||= $ENV{OZEKI_NG_SMS_PASSWORD}; pod2usage( -verbose => 2, -message => "\nYou're missing required arguments.\n" ) unless $recipient and $user and $password; my $size = $message ? length $message : 0; pod2usage( -verbose => 0, -message => "\nMessage is required, up to 140 characters.\n +" ) unless $size > 0 and $size <= 140; my $endpoint = URI->new("/api"); $endpoint->scheme("http"); $endpoint->host($host); $endpoint->port($port); $endpoint->query_form( action => "sendmessage", username => $user, password => $password, recipient => $recipient, messagetype => "SMS:TEXT", messagedata => $message ); my $response = LWP::UserAgent ->new( agent => "OHAIbot/3.14") ->get($endpoint); if ( $response->is_success ) { print "Successfully sent.\n"; } else { print join "\n\n", "Nice going...", $endpoint, $response->decoded_content; } exit 0; __END__ =pod =head1 Name Ozeki NG - SMS Gateway Perl example. =head1 Prerequisite Install Ozeki NG SMS Gateway, L<http://ozekisms.com>. =head1 Synopsis ./ozeki-ng-sms -user ME -pass S3CR37 -r "1234567890" -m "OHAI DER" =head2 Options C<user>, C<password>, C<recipient>, and C<message> are required. -help -host # Default is 127.0.0.1 -port # Default is 9501 -user # or set OZEKI_NG_SMS_USER -password # or set OZEKI_NG_SMS_PASSWORD -recipient # SMS number -message # Up to 140 characters =head1 See also L<http://perlmonks.org/?node_id=999542>. =head1 License Artistic 2.0. =cut

Update, added prereq to Pod.


In reply to Re: SMS from Perl using HTTP request by Your Mother
in thread SMS from Perl using HTTP request by JacobAnderson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (19)
    As of 2014-07-14 13:22 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (260 votes), past polls