我需要从 asp.net 向不同的电话号码发送短信,但我完全不知道发送短信。但是通过谷歌我得到了这段代码:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
namespace TESTING
{
public partial class SendSMS : System.Web.UI.Page
{
string uid;
string password;
string message;
string no;
protected void Page_Load(object sender, EventArgs e)
{
}
public void send()
{
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password + "&msg=" + message + "&phone=" + no + "&provider=fullonsms");
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
uid = "";
password = "";
message = MessageTextBox.Text;
no = MobileNumberTextBox.Text;
send();
MessageTextBox.Text = "";
MobileNumberTextBox.Text = "";
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
}
}
我有一个这样的asp代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendSMS.aspx.cs" Inherits="TESTING.SendSMS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Mobile No"></asp:Label>
<asp:TextBox ID="MobileNumberTextBox" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Message"></asp:Label>
<asp:TextBox ID="MessageTextBox" runat="server" TextMode="MultiLine"> </asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Send Sms" OnClick="Button1_Click" />
</div>
</form>
</body>
这段代码不适用于发送短信。我需要一个代码示例来发送短信。你的帮助对我来说意义重大。