Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Exemple en C# d'envoi de SMS unitaire
static void Main(string[] args)
// Création du XML à poster
var xml = @"<request login=""your-login"" password=""your-password"">
<push media=""sms"" type=""on_demand"" name=""Test API Sms C#"">
<message type=""text"">Mon premier test sms</message>
<add target=""+33 600000000""/>
// Construction et envoi de la requête HTTP
WebRequest request = WebRequest.Create("");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(xml);
request.ContentLength = byteArray.Length;
System.IO.Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
WebResponse web_response = request.GetResponse();
var stream_response = web_response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream_response);
string response = reader.ReadToEnd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment