DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Send SMS Using Www.smsmatrix.com Gateway In C#

07.22.2010
| 3471 views |
  • submit to reddit
        Send sms (worldwide) using www.smsmatrix.com.
More examples at <a href="http://www.smsmatrix.com">SMS Gateway</a> page.

string MATRIXURL = "http://www.smsmatrix.com/matrix";
string PHONE = "12506063167";
string USERNAME = Server.UrlEncode ("user@hotmail.com");
string PASSWORD = Server.UrlEncode ("pass72727");
string TXT = Server.UrlEncode ("This is a test, pls ignore");

string q = "username=" + USERNAME +
 "&password=" + PASSWORD +
 "&phone=" + PHONE +
 "&txt=" + TXT;

HttpWebRequest req = (HttpWebRequest)WebRequest.Create (MATRIXURL);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = q.Length;

StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write (q);
streamOut.Close();

StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string res = streamIn.ReadToEnd();
Console.WriteLine ("Matrix API Response:\n" + res);
streamIn.Close();