Showing posts with label SMS Gateway. Show all posts
Showing posts with label SMS Gateway. Show all posts

Thursday, 16 May 2013

SMS Gateway Intergration in .net



-->


using System.Text;

using System.Net;

using System.IO;

///


/// Summary description for sendsms

///


///



public class sendsms

{





public static void Main(string[] args)

{

string result = "";

WebRequest request = null;

HttpWebResponse response = null;

try

{

String sendToPhoneNumber = "xxxxxxxxx";

String userid = "xxxxx";

String passwd = "xxxxx";

String url = "http://enterprise.smsgupshup.com/GatewayAPI/rest?method=sendMessage&send_to=" + sendToPhoneNumber + "&msg=hello&userid=" + userid + "&password=" + passwd + "&v=1.1" & msg_type = TEXT & auth_scheme = PLAIN;

request = WebRequest.Create(url);

//in case u work behind proxy, uncomment the/*WebProxy proxy = new WebProxy("http://proxy:80/",true);

//proxy.Credentials = new NetworkCredential("userId","password", "Domain");

//request.Proxy = proxy;

/// Send the 'HttpWebRequest' and wait for response.response = (HttpWebResponse)request.GetResponse();

Stream stream = response.GetResponseStream();

Encoding ec = System.Text.Encoding.GetEncoding("utf-8");

StreamReader reader = new System.IO.StreamReader(stream, ec);

result = reader.ReadToEnd();

Console.WriteLine(result);

reader.Close();

stream.Close();

}

catch (Exception exp)

{

Console.WriteLine(exp.ToString());

}

finally

{

if (response != null) response.Close();

}

}



}