Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-14-2012, 02:56 PM   PM User | #1
JacobAnderson
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
JacobAnderson is an unknown quantity at this point
SMS from Perl using HTTP request

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.

[CODE]

#!/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
JacobAnderson is offline   Reply With Quote
Old 11-14-2012, 07:17 PM   PM User | #2
patryk
Regular Coder

 
patryk's Avatar
 
Join Date: Oct 2012
Location: /dev/couch
Posts: 395
Thanks: 2
Thanked 64 Times in 64 Posts
patryk is on a distinguished road
i personally prefer SMSD. you just create properly formated text file in right directory so it can be done with just one line of code. any scripting language will do that.
recieving messages is simple too - read from txt file. plus you can send binary messages like logos, vcards and stuff like that
patryk is offline   Reply With Quote
Reply

Bookmarks

Tags
gateway, http, perl, sms

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:04 AM.


Advertisement
Log in to turn off these ads.