Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java program to send sms by accessing way2sms.com site.it woks correct for login,and login successfully ,but shows error while sending sms.

What I have tried:

I tried by changing url as well,bt it not working...
here is the method,


private void getActionString()

{
URLConnector.connect("http://" + site + "/jsp/InstantSMS.jsp", false,
"GET", cookie, null);
responseCode = URLConnector.getResponseCode();
System.out.println(responseCode);
System.out.println(HttpURLConnection.HTTP_MOVED_TEMP);
System.out.println(HttpURLConnection.HTTP_OK);
if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP
|| responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_MOVED_PERM) {
String str = URLConnector.getResponse();
String aStr = "name=\"Action\" id=\"Action\"";
int aStrLen = aStr.length();
int index = str.indexOf(aStr);
System.out.println(str);
System.out.println(aStr);
if (index > 0) {
str = str.substring(index + aStrLen);
index = str.indexOf("\"");
if (index > 0) {
str = str.substring(index + 1);
index = str.indexOf("\"");
if (index > 0)
actionStr = str.substring(0, index);
//actionStr="one";
}
}
} else{System.out.println(actionStr); exit("getActionString failed!");}

URLConnector.disconnect();
}
Posted
Comments
Mehdi Gholam 10-Dec-17 0:59am    
Try reading the error message.
Member 13567425 10-Dec-17 1:05am    
Hello sir,thanks for reply,
i'm not getting actually what you are saying..
Mehdi Gholam 10-Dec-17 1:17am    
Read the response code and error message from the server.
Member 13567425 10-Dec-17 1:25am    
public static int getResponseCode()
{
int responseCode = -1;
if(connection != null)
{
try
{
responseCode = connection.getResponseCode();
}
catch(Exception exception)
{
System.err.println("Response code error");
}
}
return responseCode;
}
public static String getResponse()
{
StringBuilder response = new StringBuilder();
if(connection != null)
{
try
{
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
while((line = rd.readLine()) != null)
{
response.append(line);
response.append('\r');
}
rd.close();
}
catch(Exception exception)
{
System.err.println("Response error");
}
}
return response.toString();
}
public static String getErrorMessage()
{
StringBuilder errorMessage = new StringBuilder();

if(connection != null)
{
try
{
InputStream es = connection.getErrorStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(es));
String line;
while((line = rd.readLine()) != null)
{
errorMessage.append(line);
errorMessage.append('\r');
Richard MacCutchan 10-Dec-17 7:44am    
What is the error message? How can anyone here guess what is going wrong without proper details?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900