本文介绍了从asp.net发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何将sms网关与asp.net应用程序集成。我有sms gaeteway的用户名和密码.....但我没有得到如何实现它(链接为wsdl文件: http://api.fastalerts.in/webservice/falertservicerevised.php?wsdl [ ^ ])。 pl'z为我提供了正确的指导。 Thanxhow can i integrate sms gateway with asp.net application. I have user id and password for sms gaeteway.....but i am not getting how can i implemented it (link for wsdl file: http://api.fastalerts.in/webservice/falertservicerevised.php?wsdl[^]). pl'z provide me proper guideline for this.Thanx推荐答案protected void sndmsg_Click(object sender, EventArgs e) { //code for sending message string str = numbers.Text;//number to send message if (numbers.Text == "") { numbers.Text += "Recipient(s) field must not be empty!\n"; return; } //we creating the necessary URL string: string ozSURL = "http://127.0.0.1"; //where Ozeki NG SMS Gateway is running string ozSPort = "9501"; //port number where Ozeki NG SMS Gateway is listening string ozUser = HttpUtility.UrlEncode("admin"); //username for successful login string ozPassw = HttpUtility.UrlEncode("******"); //user's password string ozMessageType = "SMS:TEXT"; //type of message string ozRecipients = HttpUtility.UrlEncode(str); //who will get the message string ozMessageData = HttpUtility.UrlEncode(msgbox.Text); //body of message string createdURL = ozSURL + ":" + ozSPort + "/httpapi" + "?action=sendMessage" + "&username=" + ozUser + "&password=" + ozPassw + "&messageType=" + ozMessageType + "&recipient=" + ozRecipients + "&messageData=" + ozMessageData; try { //Create the request and send data to Ozeki NG SMS Gateway Server by HTTP connection HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL); //Get response from Ozeki NG SMS Gateway Server and read the answer HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse(); System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream()); string responseString = respStreamReader.ReadToEnd(); respStreamReader.Close(); myResp.Close(); //inform the user textbox.Text = responseString; // textboxError.Visible = true; } catch (Exception) { //if sending request or getting response is not successful Ozeki NG SMS Gateway Server may do not run textbox.Text = "Ozeki NG SMS Gateway Server is not running!"; textbox.Visible = true; } } //code end for sending message } 这篇关于从asp.net发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 01:31