1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

SMS from Perl using HTTP request

Discussion in 'Software Development' started by thomasqueen, Jan 23, 2013.

Thread Status:
Not open for further replies.
  1. thomasqueen

    thomasqueen Thread Starter

    Joined:
    Jan 23, 2013
    Messages:
    1
    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!"

    }

    What do you think? Thomas
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Perl using HTTP
  1. adhya.arya
    Replies:
    2
    Views:
    233
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1086503

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice