Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

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

Hey guys. For my project, I needed to find a way to send SMS messages from Perl. It turns out, it is easy to send messages from Perl using HTTP requestes and a software called Ozeki NG SMS Gateway.

To send SMS messages from Perl using HTTP requests, first you need to download, install and configure Ozeki NG SMS Gateway software to your computer. Then import the source code provided below into a new project you write in Perl. After you imported it you can configure the code. You need to customize the values in the source code below.

#!/usr/bin/perl ############################################### ## Ozeki NG - SMS Gateway Perl example ## ############################################### use HTTP::Request; use LWP::UserAgent; use URI::Escape; ############################################### ### Ozeki NG informations ### ############################################### $host = "127.0.0.1"; $port = "9501"; $username = "admin"; $password = "abc123"; $recipient = "+00123456"; $message = "Test Message from Perl"; ############################################### ### Putting together the final HTTP Request ### ############################################### $url = "http://" . $host; $url .= ":" . $port; $url .= "/api?action=sendmessage&"; $url .= "username=" . uri_escape($username); $url .= "&password=" . uri_escape($password); $url .= "&recipient=" . uri_escape($recipient); $url .= "&messagetype=SMS:TEXT"; $url .= "&messagedata=" . uri_escape("HELLO WORLD"); ################################################ #### Sending the message ### ################################################ $request = HTTP::Request->new(GET=>$url); $useragent = LWP::UserAgent->new; $response = $useragent->request($request); ################################################ ### Verifying the response ### ################################################ if ($response->is_success) { print "Message successfully sent" } else { print "Message not sent! Please check your settings!" }

You can find more info here: http://ozekisms.com/index.php?owpn=608 I hope this will be as useful to you as it is for me! Jacob


In reply to 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 rifling through the Monastery: (12)
    As of 2014-09-02 12:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (22 votes), past polls