Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-03-19 04:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found