Code Sample:
void Page_Load(Object Src, EventArgs E)
{
myPage.Text = readHtmlPage("https://www.bulksmsgateway.in/sendmessage.php");
}
private String readHtmlPage(string url)
{
String result = "";
String message = HttpUtility.UrlEncode("Hello world!");
String strPost = "?user=9030888111&password=password&msg=" + message + "&sender=OPTINS" + "&mobile=+989035143135" + "&type=1";
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = Encoding.UTF8.GetByteCount(strPost);
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
return e.Message;
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
Please note that some of the above code has been supplied to Bulk SMS Gateway
by clients. As such, accuracy is not guaranteed by Bulk SMS Gateway.