Java and the gateway

Java and the gateway SearchSearch
Author Message
Anonymous
 
Posted on Sunday, June 13, 2004 - 08:48 pm:   

can i let the java controls the 2way sms throw the gateway
M.A.M.F
New member
Username: Mamf

Post Number: 6
Registered: 06-2004
Posted on Tuesday, June 15, 2004 - 04:51 pm:   

yes u can using the Java Script in windows scripting.
there is a thread contains a sample for this but i lost it's refrence, i have a copy of the reply posted by Bryce (nowsms expert) and i will post it here again
--------------------------------------
BRYCE Posting Was:
We have an HTTP command interface in NowSMS, where you can send a message by issuing an HTTP GET request to the gateway. (At a very simple level, this is a matter of connecting to the configured port on the gateway and issuing a command "GET /?PhoneNumber=xxxx&Text=text+of+message HTTP/1.0\r\n\r\n". Note that the text needs to be URL escaped according to HTTP specifications.)

If you're in the Windows environment, and you need to send a message through a command line interface, you could use simple scripting to create a script that runs from a command line interface.

For example, here's a real simple script.

Save the following with a file name of "sms.js", and modify the last line of the script to reference your NowSMS server, the phone number you want to send to, and the text of the message (with a little more work, you could turn those fields into variables for the script).

----- begin sms.js -----
function HTTPGET(strURL)
{
var strResult;

try
{
// Create the WinHTTPRequest ActiveX Object.
var WinHttpReq = new ActiveXObject("Msxml2.XMLHTTP" /* or "WinHttp.WinHttpRequest.5"*/);

// Create an HTTP request.
var temp = WinHttpReq.Open("GET", strURL, false);

// Send the HTTP request.
WinHttpReq.Send();

// Retrieve the response text.
strResult = WinHttpReq.ResponseText;
}
catch (objError)
{
strResult = objError + "\n"
strResult += "WinHTTP returned error: " +
(objError.number & 0xFFFF).toString() + "\n\n";
strResult += objError.description;
}

// Return the response text.
return strResult;
}

WScript.Echo(HTTPGET("http://mms.host.ip:port/?PhoneNumber=phonenumber&User=user name&password=password&text=SNMP+Trap+has+occurred"));

----- end sms.js -----

Then, you can run "cscript sms.js", which loads the Windows script host (cscript.exe) to process this script.

Hope that helps!

-bn
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2828
Registered: 10-2002
Posted on Tuesday, June 15, 2004 - 07:32 pm:   

I assume you mean that you want a received SMS to call a Java app?

Setup the Java app on a web server so that it can receive SMS information in URL request parameters (e.g., http://server/test.app?sender=1234&text=xyz)

Then you can configure NowSMS to call that URL every time a message is received, passing the sender information and text of the message.

-bn