| Author |
Message |
Mahaboob Basha
New member Username: Basha
Post Number: 5 Registered: 11-2008
| | Posted on Monday, December 01, 2008 - 10:56 am: | |
Hi iam developing one application where i need to send a sms from tomcat server to mobile phone through some gateway can any one help me in this.. similarly i need to receive sms from mobile to tomcat server... how to do this.. iam using nowsms as a gateway and i connected mobile as a modem.. |
Des - NowSMS Support
Board Administrator Username: Desosms
Post Number: 279 Registered: 08-2008
| | Posted on Monday, December 01, 2008 - 05:38 pm: | |
Hi, You need to use an HTTP Java library such as Apache HttpClient. You issue an HTTP URL request from your Java application to the NowSMS server, using the URL formats described here: http://www.nowsms.com/documentation/ProductDocumentation/sending_messages/sendin g_text_messages.htm http://www.nowsms.com/documentation/ProductDocumentation/sending_messages/url_pa rameters_for_sending_messages.htm You should also be able to use the built-in URLConnection or HTTPURLConnection class to accomplish this. For processing received messages, you configure a URL for processing received messages in the "2-way" page of the NowSMS configuration. When NowSMS receives an SMS message, it connects to the URL that you specify, subsituting parameters for the phone number of the sender, text of the message, etc. Test your application by issuing the URL request from a web browser first, then plug it into the 2-way SMS command table in NowSMS when you are ready to test it live. -- Des NowSMS Support |
Sajid Ahmed
New member Username: Sajid
Post Number: 5 Registered: 10-2008
| | Posted on Tuesday, December 02, 2008 - 11:00 am: | |
Hi Friend, Hope code below helps you to send message to nowsms using java..Can some one help for creating mms message using JAVA ? String phone=""; String message=""; String ppgHost=""http://localhost:8800/"; try{ phone=URLEncoder.encode(getMobileId(), "UTF-8"); if(debug) System.out.println("phone---->"+phone); message=URLEncoder.encode(getMessage(), "UTF-8"); if(debug) System.out.println("message---->"+message); } catch (UnsupportedEncodingException e) { System.out.println("Encoding not supported"); } String url_str=ppgHost+"?PhoneNumber="+phone+"&Text="+message; if(debug) System.out.println("path name---url_str----->"+url_str); URL url2=new URL(url_str); HttpURLConnection connection = (HttpURLConnection) url2.openConnection(); connection.setDoOutput(false); connection.setDoInput(true); if(debug) System.out.println("connection :"+connection); String res=connection.getResponseMessage(); if(debug) System.out.println("res :"+res); int code = connection.getResponseCode () ; if ( code == HttpURLConnection.HTTP_OK ) { connection.disconnect() ; } To recive sms u need to do 2-way commnunication using http as below to invoke ur servlet "*" means all comming request ReceiveSMSCommand1=* http://localhost:port/webapplication/servlet?sender=@@SENDER@@&message=@@FULLSMS @@&route=@@SMSCROUTE@@&systemtype=@@SERVICETYPE@@ No hope this resolev your problem.. Thanks & Regards, Sajid +919985032322 |
Des - NowSMS Support
Board Administrator Username: Desosms
Post Number: 285 Registered: 08-2008
| | Posted on Tuesday, December 02, 2008 - 03:46 pm: | |
Hi Sajid, Thanks for sharing that script example. I do have a link for Java code to send an MMS message via NowSMS. It requires Apache HTTPClient. http://www.nowsms.com/discus/messages/485/1360.html -- Des NowSMS Support |
Des - NowSMS Support
Board Administrator Username: Desosms
Post Number: 301 Registered: 08-2008
| | Posted on Monday, December 08, 2008 - 08:47 pm: | |
A few notes on Sajid's example... In order to send a message using that Java code, it is assumed that you change the following variables at the start of the code: String phone=""; String message=""; String ppgHost="http://localhost:8800/"; The phone variable is set to the recipient phone number to receive the message. The message variable is set to the text of the message being sent. The ppgHost variable is set to a URL for connecting to the NowSMS web interface. If you have user accounts enabled on NowSMS, you need to modify the following line: String url_str=ppgHost+"?PhoneNumber="+phone+"&Text="+message; to: String url_str=ppgHost+"?user=username&password=password"+"&PhoneNumber="+phone+"&Text= "+message; Where "username" and "password" are the credentials of an "SMS Users" account defined on the NowSMS server. |
Des - NowSMS Support
Board Administrator Username: Desosms
Post Number: 321 Registered: 08-2008
| | Posted on Thursday, December 11, 2008 - 05:13 pm: | |
People are complaining about the following error from the above example:
quote:Smssending.java:18: cannot find symbol symbol : method getMobileId() location: class Smssending phone=URLEncoder.encode(getMobileId(), "UTF-8"); ^ Smssending.java:21: cannot find symbol symbol : method getMessage() location: class Smssending message=URLEncoder.encode(getMessage(), "UTF-8"); ^ 2 errors
I am not a Java expert, but I am guessing that the functions getMobileId() and getMessage() simply are not defined. I suspect the person who originally wrote this code used those functions, but then to try to give you a quick example, took the functions out, and substituted in variable settings ... but didn't modify the code. I would change "getMobileId()" to "phone" ... and "getMessage()" to "message". (Do not include the "quote" characters, I am just using them as delimiters to indicate what text should be changed.) |
PHILIP TEO
New member Username: Philip_teoph
Post Number: 2 Registered: 02-2009
| | Posted on Wednesday, February 04, 2009 - 08:57 am: | |
Attached please working java code to send sms via Now.SMS.
|
Des - NowSMS Support
Board Administrator Username: Desosms
Post Number: 424 Registered: 08-2008
| | Posted on Wednesday, February 04, 2009 - 08:18 pm: | |
Thanks! Your example inspired me to brush up on my Java skills. I've uploaded a more flexible Java example for NowSMS at the following link: http://www.nowsms.com/download/sendsms.java.txt More information and explanation of how to use this Java code can be found here: http://blog.nowsms.com/2009/02/nowsms-java-example-send-sms-message.html -- Des NowSMS Support |
deepariya
New member Username: Deepa
Post Number: 1 Registered: 04-2009
| | Posted on Monday, April 20, 2009 - 07:39 am: | |
hi i got the following error pls can anyone help me thanx in advance phone------>8366xxxx message---->SendMsg+via+Now.SMS url string->http://127.0.0.1:8800/?PhoneNumber=8366xxxx&Text=SendMsg+via+Now.SMS Opened Con->sun.net.www.protocol.http.HttpURLConnection:http://127.0.0.1:8800/?PhoneNumber=8366xxxx& Text=SendMsg+via+Now.SMS unable to create new urlConnection refused: connect |
deepariya
New member Username: Deepa
Post Number: 2 Registered: 04-2009
| | Posted on Monday, April 20, 2009 - 11:36 am: | |
code will be executed successfully but i didn't get a sms........ |
Des - NowSMS Support
Board Administrator Username: Desosms
Post Number: 694 Registered: 08-2008
| | Posted on Monday, April 27, 2009 - 08:42 pm: | |
Do you have NowSMS installed????? Is NowSMS configured to listen on port 8800 as its "port number for web interface"? |