从Asp.net应用程序发送推送SMS

从Asp.net应用程序发送推送SMS,asp.net,sms,push,Asp.net,Sms,Push,请让我知道的方法,我如何可以发送推短信到手机号码从asp.net应用程序。提前感谢。请试用此代码 protected void Page_Load(object sender, EventArgs e) { textboxRecipient.Width = 400; textboxMessage.Width = 450; textboxMessage.Rows = 10; textboxError.Width = 400; textboxError.Row

请让我知道的方法,我如何可以发送推短信到手机号码从asp.net应用程序。提前感谢。

请试用此代码

protected void Page_Load(object sender, EventArgs e)
{
    textboxRecipient.Width = 400;
    textboxMessage.Width = 450;
    textboxMessage.Rows = 10;
    textboxError.Width = 400;
    textboxError.Rows = 5;

    textboxError.ForeColor = System.Drawing.Color.Red;
    textboxError.Visible = false;
    textboxError.Text = "";

    if (!Page.IsPostBack)
    {
        textboxRecipient.Text = "+7588451632";
        textboxMessage.Text = "Hello World!";
    }
}

protected void buttonSendOnClick(object sender, EventArgs e)
{
    //are required fields filled in:
    if (textboxRecipient.Text == "")
    {
        textboxError.Text += "Recipient(s) field must not be empty!\n";
        textboxError.Visible = true;
        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("abc123"); //user's password
    string ozMessageType = "SMS:TEXT"; //type of message
    string ozRecipients = HttpUtility.UrlEncode(textboxRecipient.Text); //who will get the message
    string ozMessageData = HttpUtility.UrlEncode(textboxMessage.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
        textboxError.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
        textboxError.Text = "Ozeki NG SMS Gateway Server is not running!";
        textboxError.Visible = true;
    }

}
试试这个代码

protected void Page_Load(object sender, EventArgs e)
{
    textboxRecipient.Width = 400;
    textboxMessage.Width = 450;
    textboxMessage.Rows = 10;
    textboxError.Width = 400;
    textboxError.Rows = 5;

    textboxError.ForeColor = System.Drawing.Color.Red;
    textboxError.Visible = false;
    textboxError.Text = "";

    if (!Page.IsPostBack)
    {
        textboxRecipient.Text = "+7588451632";
        textboxMessage.Text = "Hello World!";
    }
}

protected void buttonSendOnClick(object sender, EventArgs e)
{
    //are required fields filled in:
    if (textboxRecipient.Text == "")
    {
        textboxError.Text += "Recipient(s) field must not be empty!\n";
        textboxError.Visible = true;
        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("abc123"); //user's password
    string ozMessageType = "SMS:TEXT"; //type of message
    string ozRecipients = HttpUtility.UrlEncode(textboxRecipient.Text); //who will get the message
    string ozMessageData = HttpUtility.UrlEncode(textboxMessage.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
        textboxError.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
        textboxError.Text = "Ozeki NG SMS Gateway Server is not running!";
        textboxError.Visible = true;
    }

}

对不起,我要的是推送短信而不是普通短信。让我知道,如果这将有一些其他的事情要做。对不起,但我正在寻找推短信,而不是正常的短信。让我知道这是否还有其他事情要做。是否存在用于此类功能的库?是否存在用于此类功能的库?