My Computer Forum Computer Science Forum

Go Back   My Computer Forum > Computer Science Forum > Networking

Networking Computer Network, Data Network, Telecommunications Network - Exchange of data between computers along cable or wireless media network links


Reply
 
LinkBack Thread Tools Display Modes
January 23rd, 2013, 03:18 AM   #1
 
Joined: Jan 2013
Posts: 1
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.

#!/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! Thomas
thomasqueen is offline  
 

My Computer Forum is free to register and we welcome everyone!

February 2nd, 2013, 10:05 AM   #2
Site Founder
 
julien's Avatar
 
Joined: Dec 2007
Posts: 414
Re: SMS from Perl using HTTP request

Great, how much does sending SMS from HTTP cost you ?
julien is offline  
Reply

  My Computer Forum > Computer Science Forum > Networking

Tags
http, perl, request, sms



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Media request! abbybeall New Users 0 February 7th, 2014 05:13 AM
Introduction to Perl asbo Programming 0 May 1st, 2010 02:49 AM





Copyright © 2017 My Computer Forum Forum. All rights reserved.