Thursday 13 March 2014

HTTP API SMS gateway in C#


using System;
using System.IO;
using System.Net;
using System.Text;
namespace SMSGateway
{
    class Program
    {
        static void Main(string[] args)
        {
            const string userId = "UserName";
            const string password = "Password";
            const string phoneNo = "Enter Mobile Number";
            const string serviceId = "WebSMS";
            const string message = "Test SMS From bulksms";
            const string url = "http://bulksms.w2wts.com/API_SendSMS.aspx?User=" + userId + "&passwd= " + password + "&mobilenumber=" + phoneNo + "&message=" + message + "&sid=" + serviceId + "&mtype=N&DR=N";
            string response = SmsAlerts.GetResponse(url);
            Console.Write(response);
            Console.ReadKey();
        }
    }
    public class SmsAlerts    {
        public static string GetResponse(string url)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.MaximumAutomaticRedirections = 4;
            request.Credentials = CredentialCache.DefaultCredentials;
            var response = (HttpWebResponse)request.GetResponse();
            Stream receiveStream = response.GetResponseStream();
            var readStream = new StreamReader(receiveStream, Encoding.UTF8);
            string responseStatus = readStream.ReadToEnd();
            response.Close();
            readStream.Close();
            return responseStatus;
        }
   
    }
}

5 comments:

  1. Too cool!
    I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a designer to create your theme?
    Excellent work!

    Bulk SMS Gateway Software

    ReplyDelete
    Replies
    1. Hi Moco Live, Thanks for your complement. My theme is the default one provided by Blogger. I just added Java Script for the menus.

      Delete
  2. Your code looks very interesting. How is it implemented however, in Sharepoint 2013? The Configure Mobile Account settings in CA only allow for a URL, Username, and Password. Is your API useable as the "Alert Me" SMS mobile account in Sharepoint 2013? Is the code used as a webpage or webservice? Is it deployed as a solution? Please post more details.

    ReplyDelete
  3. Marketing92 is helping their customers to expand your business with our Best services of Branded SMS in Lahore. On our online Branded SMS Portal customers can send SMS for Campaigns, Discount, Alerts and sales. Use our Bulk SMS in Lahore and SMS Marketing in Lahore to get more customers and increase your Profit.

    ReplyDelete
  4. Thanks for sharing code SMS API through C# . We also provide Bulk SMS API services using different language like C#,PHP,Java,VB,asp.Thanks for sharing.

    ReplyDelete