Sample code for how to send SMS in java using HTTP Requests

import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class SendSMS {
public static void main(String[] args) {
try {
String requestUrl  = "http://sms.cellapps.com/sendsms.php?"+
"UserId=" +    URLEncoder.encode("XXXX", "UTF-8") +
"&Pwd=" +      URLEncoder.encode("XXXX", "UTF-8") +
 "&Mobileno=" + URLEncoder.encode("XXXX", "UTF-8") +
 "&Msg=" +      URLEncoder.encode("This is test sms", "UTF-8") +
 "&SenderId=" + URLEncoder.encode("Alert", "UTF-8");

System.out.println("URL : "+requestUrl);
URL url = new URL(requestUrl);
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
System.out.println("Request Status code : " +uc.getResponseCode());
if(uc.getResponseCode()== 200){
System.out.println("Message Send Successfully");
}
uc.disconnect();
} catch(Exception ex) {
System.out.println("Error :while sending Message");
System.out.println(ex);
}
}
}

Comments

  1. It is very easy, you have to sign up an account at MsgClub and go to developer tool for Javascript. We will provide you simple steps to integrate Bulk SMS API Java into your website/application/software.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Install AnyDesk remote desktop client on Ubuntu

How to install Jaspersoft Studio on Eclipse

What is Advanced Encryption Standard (AEC) and online tool to encrypt and decrypt data using AEC.