International Bulk SMS Messaging Service Provider, Reseller UAE - BroadNet Technologies

Home Location Register

Sample Code

Java Sample Code

Your Subtitle Goes Here
;
//Android SMS API integration code

//Your application url
String ApiUrl = "ApiUrl";

//Your User Id
String user = "user";

//Your password
String pass = "****";


//Multiple mobiles numbers separated by comma
String mobiles = "9999999";
//Sender ID,While using route4 sender id should be 6 characters long.
String sid = "102234";
//Your message to send, Add URL encoding here.
String message = "Test message";

URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null; 

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

//Send SMS API
String mainUrl="https://broadnet.mme/api/xxxx.php?";

//Prepare parameter string
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append("user="+user); 
sbPostData.append("&pass="+pass);
sbPostData.append("&mobiles="+mobiles);
sbPostData.append("&message="+encoded_message);
sbPostData.append("&sid="+sid);

//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();
} 

PHP Sample Code

Your Subtitle Goes Here
;
//PHP SMS API integration code 
//Your application url 
$ApiUrl ="ApiUrl";)

//Your User Id
$user ="user";

//Your password
$pass ="****";

//Multiple mobiles numbers separated by comma
$mno = "9999999";

//Sender ID,While using route4 sender id should be 6 characters long.
$sid = "102234";

//Your message to send, Add URL encoding here.
$text = "Test message";

// Message Type (1,2,3,4) 1- English,2-Unicode,3- Special Character,4-Arabic
$type = "type";

//Prepare parameter string
$url = "$ApiUrl?user=$user&pass=$pass&sid=$sid&mno=$mno&text=$text&type=$type";

//prepare connection
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

//reading response
$body = curl_exec($ch);

//finally close connection
curl_close($ch);

//print response 
echo $body;

 

Python Sample Code

Your Subtitle Goes Here
;
  class SmsAPI(object): 
        # <summary> 
        # Specify complete Url of SMS gateway 
        # </summary> 
        def get_ApiUrl(self):

        def set_ApiUrl(self, value):

        ApiUrl = property(fget=get_ApiUrl, fset=set_ApiUrl)

        # <summary> 
        # User name supplied by provider 
        # </summary> 
        def get_user(self):

	   def set_user(self, value):

	   user = property(fget=get_user, fset=set_user)

        # <summary> 
        # Password supplied by provider 
        # </summary>  
        def get_pass(self):

	   def set_pass(self, value):

	   pass = property(fget=get_pass, fset=set_pass)
     
        # <summary> 
        # SID supplied by provider 
        # </summary>  
        def get_sid(self):

	    def set_sid(self, value):

	    sid = property(fget=get_sid, fset=set_sid)

	    def __init__(self, ApiUrl, user, pass, sid):
		   self.ApiUrl = ApiUrl
		   self.user = user
		   self.pass = pass
		   self.sid = sid

	    def __init__(self, ApiUrl, user, pass, sid):
		   self.ApiUrl = ApiUrl
		   self.user = user
		   self.pass = pass
		   self.sid = sid

          def SendSMS(self, Recipient, MessageData):
		   if self.ApiUrl.Trim() == "" or self.user.Trim() == "" or self.pass.Trim() == "" or self.sid.Trim() == "":
		  	raise Exception("All Properties were required")
		   #Status = SMS(User, SURL, SPort, Passw, number, MessageData, MessageType); //Sending SMS 
		   #///// string createdURL = "http://78.108.164.67" + ":" + "8080" + "/websmpp/websms" +
		   #/////"?user=" + "SPDDLC" +
		   #/////"&pass=" + "s@KJ8QH9" +
		   #/////"&sid=" + "SPDDLC" +
		   #/////"&mno=" + Recipient +
                   #/////"&text=" + MessageData +
		   #/////"&type=" + "1" +
		   #/////"&esm=" + "0" +
		   #/////"&dcs=" + "0";
		   # MessageBox.Show(createdURL);
		   createdURL = self.ApiUrl + "?user=" + self.user + "&pass=" + self.pass + "&sid=" + self.sid + "&mno=" + Recipient + "&text=" + MessageData + "&type=" + "1" + "&esm=" + "0" + "&dcs=" + "0"
                   try:
			myReq = WebRequest.Create(createdURL)
			#MessageBox.Show("2");
			# Get response from SMS Gateway Server and read the answer
			myResp = myReq.GetResponse()
			# MessageBox.Show("21");
			respStreamReader = System.IO.StreamReader(myResp.GetResponseStream())
			# MessageBox.Show("22");
			responseString = respStreamReader.ReadToEnd()
			#  MessageBox.Show("2");
			respStreamReader.Close()
			myResp.Close()
		except Exception, ex:
			raise ex
		finally:
		return "success"

 

C# Sample Code

Your Subtitle Goes Here
;
public class SmsAPI 
        { 
        /// <summary> 
        /// Specify complete Url of SMS gateway  
        /// </summary> 
        public string ApiUrl { get; set;  } 
        /// <summary> 
        /// User name supplied by provider  
        /// </summary> 
        public string user { get; set;  } 
        /// <summary> 
        /// Password supplied by provider  
        /// </summary> 
        public string pass { get; set;  } 
        /// <summary> 
        /// SID supplied by provider  
        /// </summary> 
        public string sid { get; set;  }           
        
        public SmsAPI()
        { 

        } 
        
        public SmsAPI(string ApiUrl, string user, string pass, string sid)
        { 
            this.ApiUrl = ApiUrl;
            this.user = user;
            this.pass = pass;
            this.sid = sid;
        } 
        
        public string SendSMS(string Recipient, string MessageData)
        { 
            if (ApiUrl.Trim() == "" || user.Trim() == "" || pass.Trim() == "" || sid.Trim() == "")
                throw new Exception ("All Properties were required");

                //Status = SMS(User, SURL, SPort, Passw, number, MessageData, MessageType); //Sending SMS 
                //////// string createdURL = "http://78.108.xxx.xx" + ":" + "8080" + "/websmpp/websms" +
                ////////"?user=" + "SPDDLC" +
                ////////"&pass=" + "s@KJ8QH9" +
                ////////"&sid=" + "SPDDLC" +
                ////////"&mno=" + Recipient +
                ////////"&text=" + MessageData +
                ////////"&type=" + "1" +
                ////////"&esm=" + "0" +
                ////////"&dcs=" + "0";

                // MessageBox.Show(createdURL);
                string createdURL = ApiUrl +
                "?user=" +user +
                "&pass=" + pass +
                "&sid=" + sid +
                "&mno=" + Recipient +
                "&text=" + MessageData +
                "&type=" + "1" +
                "&esm=" + "0" +
                "&dcs=" + "0";

                try
                 { 
                    
                    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
                    //MessageBox.Show("2");
                    // Get response from SMS Gateway Server and read the answer 
                    HttpWebRequest myResp = (HttpWebRequest)myReq.GetResponse();
               
                    // MessageBox.Show("21");
                    System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
                    // MessageBox.Show("22");
                    string responseString = respStreamReader.ReadToEnd();
                    //  MessageBox.Show("2");
                    respStreamReader.Close();
                    myResp.Close();

                } 
                  catch (Exception ex)
                     {
                          throw ex;
                     }
                     finally
                     {
               
                     }
                     return "success";
        } 
      } 
   }