Thursday 19 April 2018

SMS Configuration using sms horizon API

Step 1 - Login Sms horizon & get username & API key (http://smshorizon.co.in/api/sendsms.php?user=Mufas&apikey=LPDkKtHkmkRk8XEtbjrt&mobile=9620367054&message=welcome&senderid=saleem&type=txt)

Step 2 - Create Portet.properties inside resources folder

This is my user name & my api

smsuserid=mufas
password=LPDkKtHkmkRk8XEtbjrt
message= Thank you for submitting you feedback.
smsapi=http://smshorizon.co.in/api/sendsms.php?

Step 3 - Call sendsms() method in controller.

  public void sendMsg() throws UnsupportedEncodingException {
  System.out.println("SMS Working complaint #########################");
  Configuration configuration = ConfigurationFactoryUtil.getConfiguration(PortalClassLoaderUtil.getClassLoader(), "portlet");
 
  String userName = configuration.get("smsuserid");
  String password = configuration.get("password");
  String textMessage = configuration.get("message");
  String smsapi = configuration.get("smsapi");
  StringBuilder smsSenderURLQueryString = new StringBuilder();
  smsSenderURLQueryString.append("user="
+ URLEncoder.encode(userName, "UTF-8"));
smsSenderURLQueryString.append("&apikey="
+ URLEncoder.encode(password,
"UTF-8"));
smsSenderURLQueryString.append("&mobile="
+ URLEncoder.encode("9620367054", "UTF-8"));
smsSenderURLQueryString.append("&message="
+ URLEncoder.encode(textMessage, "UTF-8"));
smsSenderURLQueryString.append("&senderid="
+ URLEncoder.encode("MYTEXT", "UTF-8"));
smsSenderURLQueryString.append("&type=" + "TXT");
String completeSenderURLString = smsapi +smsSenderURLQueryString.toString();
HttpURLConnection connection = null;
URL completeSenderURL = null;
String conncetionResponse = null;
try{
completeSenderURL = new URL(completeSenderURLString);
connection = (HttpURLConnection) completeSenderURL.openConnection();
connection.setDoOutput(false);
connection.setDoInput(true);
conncetionResponse = connection.getResponseMessage();
int responseCode = connection.getResponseCode();
String responseMessage = connection.getResponseMessage();
}catch(Exception e){

}
  }

2 comments:

  1. Thanks for sharing. A Bulk SMS API provider makes it possible for companies to be available and visible to their prospective customers by sending them detailed and promotional messages about their products and services.

    ReplyDelete
  2. Thanks for sharing this blog. A Bulk SMS API is an application interface which allows functions of bulk messaging softwares to be used within the existing technical framework of business applications and ensure that the two key applications work harmoniously.

    ReplyDelete