private void send_sms_direct(string numbers, string sms) { if (txtmobile_direct.Text == string.Empty) { Response.Write("Please Enter Numbers"); return; } if (txtMessage.Text == string.Empty) { Response.Write("Please Enter Your Message"); return; } string authKey = "70740A9HJVjbP53e5cee9"; string mobileNumber = numbers; string senderId = "NBCHOS"; string message = HttpUtility.UrlEncode(sms); StringBuilder sbPostData = new StringBuilder(); sbPostData.AppendFormat("authkey={0}", authKey); sbPostData.AppendFormat("&mobiles={0}", mobileNumber); sbPostData.AppendFormat("&message={0}", message); sbPostData.AppendFormat("&sender={0}", senderId); sbPostData.AppendFormat("&route={0}", "4"); try { string sendSMSUri = "https://control.msg91.com/sendhttp.php"; HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(sendSMSUri); UTF8Encoding encoding = new UTF8Encoding(); byte[] data = encoding.GetBytes(sbPostData.ToString()); httpWReq.Method = "POST"; httpWReq.ContentType = "application/x-www-form-urlencoded"; httpWReq.ContentLength = data.Length; using (Stream stream = httpWReq.GetRequestStream()) { stream.Write(data, 0, data.Length); } HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string responseString = reader.ReadToEnd(); reader.Close(); response.Close(); } catch (SystemException ex) { Response.Write(ex.Message.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)