using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; using System.Xml; namespace SendSMS { class SendSMS { static void Main(string[] args) { // The url for sending SMS string url = "http://www.agendize.com/api/1.0/action?media=sms&key=3ac024abf8c72460764b965199f81808f5dc19&id=142514&phone=+33611111111"; // Establish the request HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); // set the authentication string authInfo = "myusername:mypassword"; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); req.Headers["Authorization"] = "Basic " + authInfo; // Set properties req.Timeout = 5000; // 5 secs // Retrieve request info headers HttpWebResponse webResponse = (HttpWebResponse)req.GetResponse(); Encoding enc = Encoding.GetEncoding(1252); // Windows default Code Page StreamReader responseStream = new StreamReader(webResponse.GetResponseStream(), enc); string xmlContent = responseStream.ReadToEnd(); webResponse.Close(); responseStream.Close(); // Retrieve AgendiZe response code obtained by searching in the parsed xml content XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlContent); XmlNodeList listeNoeud = xmlDoc.GetElementsByTagName("result"); // Display the response code Console.WriteLine(listeNoeud.Item(0).InnerText); } } }