Developer Tools
BasicText SMSCampaignSendOTPVirtual NumberResellerSample CodePhonebookError Code
HOME LOGIN SIGN UP
  • Send SMS in PHP
  • Send SMS in Python
  • Send SMS in JAVA
  • Send SMS in JAVA For XML API
  • Send SMS in C#
  • Send SMS in Google Appscript
  • Send SMS in Windows 8
  • Send SMS in Android
  • Send SMS in iOS
  • Send SMS in VB6
  • Send SMS in Oracle
  • Send SMS in Go Language
  • Api Postman Collection

HTTP Send SMS API Using Android

Code:

//Your authentication key
String authkey = "YourAuthKey"; //Multiple mobiles numbers separated by comma
String mobiles = "9999999"; //Sender ID,While using route4 sender id should be 6 characters long.
String senderId = "102234"; //Your message to send, Add URL encoding here.
String message = "Test message"; //define route
String route="default";
URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null;
//encoding message
String encoded_message=URLEncoder.encode(message);
//Send SMS API
String mainUrl="http://api.msg91.com/api/sendhttp.php?";
//Prepare parameter string
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append("authkey="+authkey);
sbPostData.append("&mobiles="+mobiles);
sbPostData.append("&message="+encoded_message);
sbPostData.append("&route="+route);
sbPostData.append("&sender="+senderId);

//final string
mainUrl = sbPostData.toString(); try
{
//prepare connection
myURL = new URL(mainUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));

//reading response
String response;
while ((response = reader.readLine()) != null) //print response
Log.d("RESPONSE", ""+response);

//finally close connection
reader.close(); }
catch (IOException e) {
e.printStackTrace();
}

© 2008-2025 | All Rights Reserved.