sending simple text sms to mobile phone through Nowsms gateway us...

sending simple text sms to mobile phone through Nowsms gateway us... SearchSearch
Author Message
Mahaboob Basha
New member
Username: Basha

Post Number: 8
Registered: 11-2008
Posted on Tuesday, December 09, 2008 - 08:01 am:   

HI when i tried to execute the following code iam getting the following errors.. plz let me know do i need to set classpath for any jar files.

here is my code..plz let me know the teps to follow to execute this program.. plz help me asap.. it s ver required to me..

import java.net.*;
import java.io.*;
import javax.swing.*;
import javax.net.ssl.HttpsURLConnection;


class Smssending
{

public static void main(String args[])
{
boolean debug=true;

String phone="+91988698866";
String message="Hi welcome to new technologies";
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() ;

}


}
}

iam getting the following error.. i know becoz of those two variables iam getting the error but how to decare that method getmobileid() and getMessage().


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
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 307
Registered: 08-2008
Posted on Tuesday, December 09, 2008 - 09:34 pm:   

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.)
Sajid Ahmed
New member
Username: Sajid

Post Number: 6
Registered: 10-2008
Posted on Saturday, December 13, 2008 - 05:58 pm:   

Hi Mahaboob,

hope this wud resolve your problem.

import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.io.UnsupportedEncodingException;
class Smssending
{

public static void main(String args[])
{
boolean debug=true;

String phone="+91988698866";
String message="Hi welcome to new technologies";
String ppgHost="http://localhost:8800/";
try{
phone=URLEncoder.encode(phone, "UTF-8");
if(debug)
System.out.println("phone---->"+phone);
message=URLEncoder.encode(message, "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() ;

}


}
}


Thanks & Regards,

Sajid
Imraj sk
New member
Username: Imraj

Post Number: 7
Registered: 12-2008
Posted on Sunday, December 14, 2008 - 05:18 am:   

Hi can any one send me the java code to retrive MSIDSN,IMEI,SMSC when any sms comes to Nowsms gateway.For example when some one sends sms from thier mobile it has to come to server through nowsms gateway and i need to store them in the database .. please send me the java code to achive this.. or else plz assist me to solve this..

Thanks&Regards
Imraj
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 335
Registered: 08-2008
Posted on Monday, December 15, 2008 - 10:59 pm:   

Hi Imraj,

All of that information is not available when you receive an SMS.

The MSISDN is availble (this is the @@SENDER@@ variable in your 2-way URL).

The SMSC from which the message is being received is available in limited situations ... only when messages are received via a GSM modem. (Other SMS interfaces do not present this information.) For GSM modem configurations, you can include @@RECEIVEDSMSC@@ in your 2-way URL which will be replaced with this information.

IMEI (or IMSI) information is not available with a received SMS.

--
Des
NowSMS Support
peter
New member
Username: Union111

Post Number: 2
Registered: 11-2008
Posted on Sunday, February 08, 2009 - 08:22 am:   

[unrelated spam deleted by admin]
Sajid Ahmed
New member
Username: Sajid

Post Number: 28
Registered: 10-2008
Posted on Sunday, February 08, 2009 - 05:24 pm:   

Hi Des,

Its really bad to have so many postings!please do some thing probobly delt this a/c :-(

Thanks
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 448
Registered: 08-2008
Posted on Monday, February 09, 2009 - 03:38 pm:   

Spam like that always puzzles me...I can't believe