.NET Examples

 

Example of a .NET Bulk SMS Gateway / API integration

For more information regarding the bulk sending API click here.

A simple example for sending SMS via a .NET method

Here’s a stand-alone .Net method:

private static string SendSms(string p_userName, string p_password, string p_orig, string p_number, string p_message, bool p_respondInXml) {

StringBuilder requestUrl = new StringBuilder();
requestUrl.Append(http://www.textmarketer.biz/gateway/);
requestUrl.Append(“?username=”).Append(HttpUtility.UrlEncode(p_userName));
requestUrl.Append(“&password=”).Append(HttpUtility.UrlEncode(p_password));
requestUrl.Append(“&orig=”).Append(HttpUtility.UrlEncode(p_orig));
requestUrl.Append(“&number=”).Append(p_number);
requestUrl.Append(“&message=”).Append(HttpUtility.UrlEncode(p_message));
if (p_respondInXml) {
requestUrl.Append(“&option=”).Append(“xml”);
}
WebRequest webRequest = HttpWebRequest.Create(requestUrl.ToString());
WebResponse webResponse = webRequest.GetResponse();
Stream responseStream = webResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream);
return streamReader.ReadToEnd();
}
And here’s an example of calling it:

string response = SendSms(“MyUsername”, “MyPassword”, “MyNumber”, “4477777777″, “This is a test”, true);


  • Share/Bookmark

 

Discussion

What do you think? Leave a comment. Alternatively, write a post on your own weblog; this blog accepts trackbacks [trackback url].

Mentions on other sites...
  1. SMS API Gateway Spec :: Text Marketer Blog - Bulk SMS, Business SMS, SMS Gateway on January 15th, 2010 at 9:59 am:
Leave a Reply