/*
* SMSclass Copyright (C) 2005 uga
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more
* details.
*/
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace SMS_Machine
{
///
/// Summary description for send.
///
public class sms
{
private static string xmlUrl = "http://xml2.aspsms.com:5061/xmlsvr.asp";
private string orgi;
private string userkey;
private string password;
public sms()
{
}
public sms(string abs, string login, string pw)
{
this.orgi = abs;
this.userkey = login;
this.password = pw;
}
public bool send(int smsid, string number, string text, int FlashMode, int BlinkMode)
{
sendASP(smsid,number,text,FlashMode,BlinkMode,"", "");
return false ;
}
private string sendASP(int idsms, string number, string message,
int flashing,int blinking, string URLDeliveryNotification,
string URLNonDeliveryNotification)
{
string content = "\r\n"
+ "\r\n" + "" + userkey + "\r\n"
+ "" + password + "\r\n" + ""
+ orgi + "\r\n" + "\r\n"
+ "" + number + "\r\n"
+ "" + idsms + "\r\n"
+ "\r\n" + "" + HttpUtility.HtmlEncode(message)
+ "\r\n" + "" + flashing
+ "\r\n"
+ "" + blinking + "\r\n"
+ ""
+ URLDeliveryNotification + "id=\r\n"
+ "" + URLNonDeliveryNotification
+ "id=\r\n"
+ "SendTextSMS\r\n" + "\r\n";
string xmlResult = "";
try
{
HttpWebRequest myWebRequest =(HttpWebRequest)WebRequest.Create(xmlUrl);
myWebRequest.Method = "POST";
myWebRequest.ContentType = "text/xml";
myWebRequest.ContentLength = content.Length;
// write the http-message body into the request stream
StreamWriter requestWriter = new StreamWriter(myWebRequest.GetRequestStream());
requestWriter.Write(content);
requestWriter.Close();
//read the response
StreamReader responseReader = new StreamReader(myWebRequest.GetResponse().GetResponseStream());
xmlResult = responseReader.ReadToEnd();
responseReader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return xmlResult;
}
}
}