如何使用现有的任何移动网络网关通过 asp.net 应用程序发送短信

How to use existing any mobile network gateway to send sms through asp.net application

我正在尝试使用现有的任何移动网络网关在 asp.net 中开发具有消息传递功能的应用程序。是否可以使用网关并使用网关通过应用程序免费发送消息。或者任何其他 API 将是完美的。寻求回应...

通过 webservice

需要通过 asp.net 发送短信的 way2sms 网关
string mbno, mseg, ckuser, ckpass;
private HttpWebRequest req;
private CookieContainer cookieCntr;
private string strNewValue;
public static string responseee;
private HttpWebResponse response;

protected void Page_Load(object sender, EventArgs e)
   {
   ckuser = "Yourusername";
   ckpass = "YourPassword";

   try
   {
     this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com/auth.cl");

     this.req.CookieContainer = new CookieContainer();
     this.req.AllowAutoRedirect = false;
     this.req.Method = "POST";
     this.req.ContentType = "application/x-www-form-urlencoded";
     this.strNewValue = "username=" + ckuser + "&password=" + ckpass;
     this.req.ContentLength = this.strNewValue.Length;
     StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
     writer.Write(this.strNewValue);
     writer.Close();
     this.response = (HttpWebResponse)this.req.GetResponse();
     this.cookieCntr = this.req.CookieContainer;
     this.response.Close();
     this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//jsp/InstantSMS.jsp?val=0");
     this.req.CookieContainer = this.cookieCntr;
     this.req.Method = "GET";
     this.response = (HttpWebResponse)this.req.GetResponse();
     responseee = new StreamReader(this.response.GetResponseStream()).ReadToEnd();
     int index = Regex.Match(responseee, "custf").Index;
     responseee = responseee.Substring(index, 0x12);
     responseee = responseee.Replace("\"", "").Replace(">", "").Trim();
     this.response.Close();

     pnlsend.Visible = true;
     lblErrormsg.Text = "connected";
   }
   catch (Exception)
   {
     lblErrormsg.Text = "Error connecting to the server...";
   }
   }




protected void btnSend_Click(object sender, EventArgs e)
   {
   mbno = txtTo.Text;//To mobile number
   mseg = txtMessage.Text;//Message

   if ((mbno != "") && (mseg != ""))
   {
     try
     {
     this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//FirstServletsms?custid=");
     this.req.AllowAutoRedirect = false;
     this.req.CookieContainer = this.cookieCntr;
     this.req.Method = "POST";
     this.req.ContentType = "application/x-www-form-urlencoded";
     this.strNewValue = "custid=undefined&HiddenAction=instantsms&Action=" + responseee + "&login=&pass=&MobNo=" + this.mbno + "&textArea=" + this.mseg;

     string msg = this.mseg;
     string mbeno = this.mbno;

     this.req.ContentLength = this.strNewValue.Length;
     StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
     writer.Write(this.strNewValue);
     writer.Close();
     this.response = (HttpWebResponse)this.req.GetResponse();

     this.response.Close();
     lblErrormsg.Text = "Message Sent..... " + mbeno + ": " + msg;
     }
     catch (Exception)
     {
     lblErrormsg.Text="Error Sending msg....check your connection...";
     }
   }
   else
   {
     lblErrormsg.Text = "Mob no or msg missing";
   }
   }
 - Above code will connect your account to way2sms please chnage code with your username and password