OZEKI NG SMS Gateway
"The World's most reliable SMS gateway software!"
info@ozekisms.com
Tel.: 00 36 52 532 731
Overview Quick start Download Manual How to buy FAQ Contact Us
OZEKI NG SMS Gateway - Product Guide

Python SMS API Contents | SearchTCL/TK SMS API

Home > Product Manual > Developers Guide > Perl SMS API

SMS Gateway SMS Gateway Home

  Product Manual
  Introduction
  SMS technology
  Installation Guide
  User Guide
  Developers Guide
  Tutorials
  ASP SMS API
  PHP SMS API
  HTTP SMS API
  SQL SMS API
  C Sharp SMS API
  AJAX SMS API
  Delphi SMS API
  Cpp SMS API
  Java SMS API
  VB.NET SMS API
  Python SMS API
  Perl SMS API
  TCL/TK SMS API
  Coldfusion SMS API
  VB 6 SMS API
  Examples and Solutions
  Appendix
  FAQ
  Feature list
  Commercial Information
  Search
 


Automated phone calls?
Ozeki Phone System XE VoIP PBX software is an advanced PBX built for automated voice calls and 2 way SMS messaging. It has outstanding APIs for software developers. It can be used for:

Phone calls from SQL
Phone calls from HTTP
Voice and SMS applications

Callcenter developers
If you are working on telephone solutions, please check out the Ozeki VoIP SIP SDK.
It can be used to create VoIP client and server software.

Contact Us!
If you wish to get further information, do not hesitate to contact us!

E-mail: info@ozekisms.com

If you have a technical question, please submit a support request on-line.

How to send SMS from Perl using HTTP request


Download: sms.pl (1,5 Mb)

In this guide you will learn how to send SMS messages from Perl using HTTP request with the help of Ozeki NG SMS Gateway. The explanation on its use and the sample source code will be provided as well.

Introduction

To send data from one application to another you can apply HTTP as it is the simplest method for this purpose. Perl has the ability to calls to submit HTTP requests, therefore it can be used to send SMS text messages to cellphones. To achieve SMS functionality you need to install a stable SMS gateway such as Ozeki NG SMS Gateway. With this software product you can operate with SMS messages with the use of HTTP GET or HTTP POST method calls (Figure 1).


Figure 1 - How to send SMS messages from Perl through HTTP.

After the installation, this solution will work as follows: to start to send SMS messages first messages have to be forwarded to the SMS Gateway. The built-in webserver of the gateway provides an HTTP SMS API that allows to submit messages. After the messages arrived at the SMS gateway they will be forwarded to the mobile network either with a GSM modem attached to the computer with a data cable, or the gateway directly connects to the SMS center of the mobile service provider over the Internet.

Prerequisites

To setup and operate this solution properly you need the follows:

Configuration

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 in the following way: In "host" variable replace 127.0.0.1. to the IP address on which Ozeki NG SMS Gateway has been installed. (In our example it is on the local computer that is why its IP address is 127.0.0.1. Replace "user_name" and "user_password" to the values with which you log into Ozeki NG SMS Gateway. Then replace the recipient to the intended recipient. In the message body you can type your message. Next, the example will piece together the HTTP request and then query it. Finally, it will verify whether the SMS sending is successful. In case of success you will read: "Message successfully sent", while if there was a problem the following message appears: "Message not sent! Please check your settings". Please note that you need to customize the values in the source code below.

Source code sample

Feel free to use and modify this source code sample!

 #!/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!"
}

Dig deeper!
People who read this also read...






Next page: TCL/TK SMS API
Copyright © 2000 - 2014 Ozeki Informatics Ltd.
All rights reserved

Software PBX for Windows | VoIP SDK   |   Legal information   |   Privacy policy   |   Terms of use
Please, address your inquiries to info@ozekisms.com