Send SMS API

API to send Transactional SMS.

API to send Transactional SMS and OTP.

		               
		
                      http://xxxxxxxxx/transactional/api?token=xxx&sender=xxx&unicode=0&number=xxx&msg=xxx
                   
						
					

unicode = 0 for english and 1 for any other language

Add Contact API

API to add Contact.

API to send Transactional SMS and OTP.

		               
		
                     http://api.themessaging.in/group/contact?token=xxxx&groupname=xxxx&no=xxxx&fname=xxx&lname=xxxx
                   
						
					

API Calling Documentation

Calling the API in Java

API to send Transactional SMS and OTP.

		               
		
                        
                        import java.io.*;
                        import java.net.URL;
                        import java.net.URLConnection;
                        import java.net.URLEncoder;
                 
                        public class SendSms{
                    
                        public static void main(String[] args)
                        {
                        //Your user name
                        String username = "reseller";
                        //Your authentication key
                        String authkey = "7165e86e31XX";
                        //Multiple mobiles numbers separated by comma (max 200)
                        String mobiles = "+919680006460";
                        //Sender ID,While using route4 sender id should be 6 characters long.
                        String senderId = "alerts";
                        //Your message to send, Add URL encoding here.
                        String message = "Test message";
                        //define route
                        String accusage="1";

                        //Prepare Url
                        URLConnection myURLConnection=null;
                        URL myURL=null;
                        BufferedReader reader=null;

                        //encoding message
                        String encoded_message=URLEncoder.encode(message);

                        //Send SMS API
                        String mainUrl="http://api.themessaging.in/transactional/api?";
             
                        //Prepare parameter string
                        StringBuilder sbPostData= new StringBuilder(mainUrl);
                        sbPostData.append("user="+username);
                        sbPostData.append("&password="+authkey);
                        sbPostData.append("&mobiles="+mobiles);
                        sbPostData.append("&sms="+encoded_message);
                        sbPostData.append("&accusage="+accusage);
                        sbPostData.append("&senderid="+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
                        System.out.println(response);
                       
                        //finally close connection
                        reader.close();
                        }
                        catch (IOException e)
                        {
                        e.printStackTrace();
                        }
                        }
                        }
                   
						
					

Calling API in PHP

Transactional SMS API

API to send Transactional SMS and OTP.

		               

     
 "http://api.themessaging.in/transactional/api?token=xxxx&sender=xxxx&unicode=0&number=919891245067&msg=hello",
  //CURLOPT_URL => "http://api.themessaging.in/transactional/api",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

print_r($response);

//$response = json_decode($response, true); //because of true, it's in an array
echo 'Online: '. $response;

?>

                     
						
					

Calling API in python

Transactional SMS API

API to send Transactional SMS and OTP.

		               
					
                         
                     import urllib # Python URL functions
                       import urllib2 # Python URL functions
                       
                       user = "reseller" # Your authentication key.
                       
                       key = "7165e86e31XX" # Your authentication key.
                       
                       mobile = "+919680006460" # Multiple mobiles numbers separated by comma.
                       
                       message = "Test message" # Your message to send.
                       
                       senderid = "alerts" # Sender ID,While using route4 sender id should be 6 characters long.
                       
                       accusage = "default" # Define route
                       
                       # Prepare you post parameters
                       values = {
                                 'user' : user,
                                 'password' : key,
                                 'mobiles' : mobile,
                                 'sms' : message,
                                 'senderid' : senderid,               
                                 'accusage' : accusage
                                 }
                       
                       
                       url = "http://api.themessaging.in/transactional/api?" # API URL
                      
                       postdata = urllib.urlencode(values) # URL encoding the data here.
                  
                       req = urllib2.Request(url, postdata)
                    
                       response = urllib2.urlopen(req)
              
                       output = response.read() # Get Response
                 
                       print output # Print Response
                
						
					

unicode = 0 for english and 1 for any other language
dynamic message example - your OTP is {otp} thanks {name}
dynamic fields example - otp=1234,name=somename

contact statuses

API Calling in C#

API to send Transactional SMS and OTP.

		               
		 
                   
                    //Your user name
                       string user = "reseller";
                       //Your authentication key
                       string password = "7165e86e31XX";
                       //Multiple mobiles numbers separated by comma
                       string mobiles = "+919680006460";
                       //Sender ID,While using route4 sender id should be 6 characters long.
                       string senderid = "alerts";
                       //Your message to send, Add URL encoding here.
                       string sms = HttpUtility.UrlEncode("Test message");
                       
                       //Prepare you post parameters
                       StringBuilder sbPostData = new StringBuilder();
                       sbPostData.AppendFormat("user={0}", user);
                       sbPostData.AppendFormat("&password={0}", password);
                       sbPostData.AppendFormat("&mobiles={0}", mobiles);
                       sbPostData.AppendFormat("&sms={0}", sms);
                       sbPostData.AppendFormat("&senderid={0}", senderid);
                       sbPostData.AppendFormat("&accusage={0}", "1");
                       
                       try
                       {
                           //Call Send SMS API
                           string sendSMSUri = "http://api.themessaging.in/transactional/api?";
                           //Create HTTPWebrequest
                           HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(sendSMSUri);
                           //Prepare and Add URL Encoded data
                           UTF8Encoding encoding = new UTF8Encoding();
                           byte[] data = encoding.GetBytes(sbPostData.ToString());
                           //Specify post method
                           httpWReq.Method = "POST";
                           httpWReq.ContentType = "application/x-www-form-urlencoded";
                           httpWReq.ContentLength = data.Length;
                           using (Stream stream = httpWReq.GetRequestStream())
                           {
                           	stream.Write(data, 0, data.Length);
                           }
                           //Get the response
                           HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
                           StreamReader reader = new StreamReader(response.GetResponseStream());
                           string responseString = reader.ReadToEnd();
                           
                           //Close the response
                           reader.Close();
                           response.Close();
                       }
                       catch (SystemException ex)
                       {
                       	MessageBox.Show(ex.Message.ToString());
                       }

     
						
					

contact statuses

API Calling in IOS

API to send Transactional SMS and OTP.

		               
		 
             //Create Objects
                       NSMutableData * responseData;
                       NSURLConnection * connection;
                       
                       // In your viewDidLoad method add this lines
                       -(void)viewDidLoad
                       {
                           [super viewDidLoad]; 
                           //Your username
                           NSString * user = @@"reseller";
                           //Your authentication key
                           NSString * authkey = @@"7165e86e31XX";
                           //Multiple mobiles numbers separated by comma
                           NSString * mobiles = @@"+919680006460"; 
                           //Sender ID,While using route4 sender id should be 6 characters long.
                           NSString * senderId = @@"alerts";
                           //Your message to send, Add URL encoding here.
                           NSString * message = @@"Test message";
                           //define route
                           NSString * route = @@"1";
                           
                           // Prepare your url to send sms with this parameters.
                           NSString * url = [[NSString stringWithFormat:@@"http://api.themessaging.in/transactional/api?user=%@@&password=%@@&mobiles=%@@&sms=%@@&senderid=%@@&accusage=%@@", user, password, mobiles, sms, senderid, accusage] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                           NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
                           connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
                       }
                       
                       // implement URLConnection Delegate Methods as follow
                       -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
                       {
                       	//Get response data
                           responseData = [NSMutableData data];
                       } 
                       
                       -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
                       {
                       	[responseData appendData:data];
                       }
                       
                       -(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
                       {
                           UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@@"Error" message:error.localizedDescription delegate:self cancelButtonTitle:nil otherButtonTitles:@@"OK", nil];
                           [alert show];
                       }
                       
                       -(void) connectionDidFinishLoading:(NSURLConnection *)connection
                       {
                           // Get response data in NSString.
                           NSString * responceStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
                       }
                       
               
						
					

API Calling in VB6

Transactional SMS API

API to send Transactional SMS and OTP.

		               
			 
         Private Sub Command1_Click()
                        
                            Dim DataToSend As String
                            Dim objXML As Object
                            Dim sms As String
                            Dim username As String
                            Dim password As String
                            Dim mobiles As String
                            Dim sender As String
                            Dim accusage As String
                            Dim URL As String
                        
                        'Set these variables
                        username = "reseller";
                        
                        password = "7165e86e31XX";
                        
                        mobiles  = "+919680006460";
                        
                        'Sender ID,While using route4 sender id should be 6 characters long.
                        sender = "alerts"; 
                        
                        ' this url encode function may not work fully functional.
                        sms = URLEncode(" Your message ")
                        
                        'Define route
                        route = "default" 
                        ' do not use https 
                        URL = "http://api.themessaging.in/transactional/api?" 
                         
                        Set objXML = CreateObject("Microsoft.XMLHTTP")
                        objXML.Open "POST", URL , False
                        objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
                            
                        objXML.send "user=" + username +"&password=" + password + "&mobiles=" + mobiles + "&sms=" + sms + "&senderid=" + sender + "&accusage=" + accusage
                        
                         If Len(objXML.responseText) > 0 Then
                                MsgBox objXML.responseText
                                
                         End If
                             
                        End Sub
                        
                        Function URLEncode(ByVal Text As String) As String
                            Dim i As Integer
                            Dim acode As Integer
                            Dim char As String
                            
                            URLEncode = Text
                            
                            For i = Len(URLEncode) To 1 Step -1
                                acode = Asc(Mid$(URLEncode, i, 1))
                                Select Case acode
                                    Case 48 To 57, 65 To 90, 97 To 122
                                        ' don't touch alphanumeric chars
                                    Case 32
                                        ' replace space with "+"
                                        Mid$(URLEncode, i, 1) = "+"
                                    Case Else
                                        ' replace punctuation chars with "%hex"
                                        URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
                                            (URLEncode, i + 1)
                                End Select
                            Next
                            
                        End Function