.NET Examples
Posted on July 27th, 2009 by Nick.
Categories: All SMS Gateway Documentation, Documentation, Technical
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);




