【发布时间】:2011-03-19 00:41:20
【问题描述】:
在我的网络应用程序中,我使用 api 发送短信,它适用于单个电话号码,但我的要求是我想向两个电话号码(手机号码)发送短信,你能帮我吗?当用户来的时候到我的网站并自动注册管理员会收到短信提醒,现在我想同时发送短信。
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
mobile =Server.HtmlEncode ( txtMobile.Text);
message = Server.HtmlEncode(txtMessage.Text);
username = Server.HtmlEncode(txtName.Text);
password = Server.HtmlEncode(txtPassword.Text);
domian = Server.HtmlEncode(txtDomain.Text);
string result = apicall("http://"+domian+"/pushsms.php?username="+username+"&password="+password+"&sender=&to="+mobile+"&message="+message);
if (!result.StartsWith("Wrong Username or Password"))
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Message Sent')", true);
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Message Sending Failed')", true);
}
sentMail()
}
catch
{
}
}
公共无效已发送邮件() { 字符串手机=“9701098107”; 字符串消息=“测试”; 字符串用户名=“xxx”; 字符串密码 = "yyyy"; 字符串 domian = "smsftt.com"; string result1 = apicall("http://" + domian + "/pushsms.php?username=" + username + "&password=" + 密码 + "&sender=&to=" + mobile + "&message=" + message); }
public string apicall(string url)
{
HttpWebRequest httpreq = (HttpWebRequest)WebRequest.Create(url);
try
{
HttpWebResponse httpres = (HttpWebResponse)httpreq.GetResponse();
StreamReader sr = new StreamReader(httpres.GetResponseStream());
string results = sr.ReadToEnd();
sr.Close();
return results;
}
catch
{
return "0";
}
}
【问题讨论】:
-
如果号码存储在一个列表中
那么你能不能只为列表中的每个电话号码调用单个发送例程? -
Mr.WestDiscGolf 实际上,当用户来到我的网站并自动注册时,管理员会收到短信提醒,现在我想同时向用户发送短信。我正在放置代码,请检查。我正在编辑我的问题,请检查一次
标签: asp.net