Wednesday, 3 April 2013

Sending SMS through ASP.NET using SMS sending API from providers.


Sending SMS through ASP.NET using SMS sending API from providers.


Hi,

Here i am describing you simplest way to send SMS using ASP.NET and API from SMS sender providers.

Whenever you will get SMS's from providers they will give you userid , password and senderid also they will provide you API to integrate with your website to send sms.

If you have any control panel from providers then you will get API from support or SMS Integration section.

To integrate this API you need to use add System.IO and System.Net namespaces.

Below is the demo code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
protected void btnSendMessage_Click(object sender, EventArgs e)
    {
        string senderusername = "xxxxx";
        string senderpassword = "xxxx";
        string senderid = "xxx";      
        string sURL;
        StreamReader objReader;
        sURL = "http://thundersms.com/smsapps/pushsms.php?username=" + senderusername + "&password=" + senderpassword + "&sender=" + senderid + "&mobile=91" + txtMobileNumber.Text + "&type=1&message=" + txtMessage.Text;
        WebRequest wrGETURL;
        wrGETURL = WebRequest.Create(sURL);
        try
        {
            Stream objStream;
            objStream = wrGETURL.GetResponse().GetResponseStream();
            objReader = new StreamReader(objStream);
            objReader.Close();
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }

Note: Please note that your send URL may be different than above. Here i am using thundersms.com API.

Below Demo Code Available for Download.

No comments:

Post a Comment