DOCUMENTAZIONE API SMS STAR
Di seguito vediamo un esempio di script in C# per eseguire le seguenti funzioni:
INVIO SMS
RICEVERE
STATO DEL SMS INVIATO
RICEVERE
COSTO DEL SMS
INVIATO
RICEVERE
IL SALDO DEI CREDITI A DISPOSIZIONE
Prima di visualizzare l'esempio di script riportato qui di seguito leggi le impostazioni da effettuare nel tuo pannello di controllo. Trovi tali indicazioni nella pagina: http://www.smsstar.it/api.htm
ESEMPIO SCRIPT IN C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { try { var XML = "XML=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SMS>\n" + "<operations>\n" + "<operation>SEND</operation>\n" + "</operations>\n" + "<authentification>\n" + "<username></username>\n" + "<password></password>\n" + "</authentification>\n" + "<message>\n" + "<sender>SMS</sender>\n" + "<text>Test message [UTF-8]</text>\n" + "</message>\n" + "<numbers>\n" + "<number messageID=\"msg11\">393333333333</number>\n" + "</numbers>\n" + "</SMS>\n"; HttpWebRequest request = WebRequest.Create("http://www.smsstar.it/account/xml.php") as HttpWebRequest; request.Method = "Post"; request.ContentType = "application/x-www-form-urlencoded"; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes(XML); request.ContentLength = data.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) throw new Exception(String.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); Console.ReadKey(); } } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } }} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { try { var XML = "XML=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SMS>\n" + "<operations>\n" + "<operation>GETPRICE</operation>\n" + "</operations>\n" + "<authentification>\n" + "<username></username>\n" + "<password></password>\n" + "</authentification>\n" + "<statistics>\n" + "<messageid>msg11</messageid>\n" + "</statistics>\n" + "</SMS>\n"; HttpWebRequest request = WebRequest.Create("http://www.smsstar.it/account/xml.php") as HttpWebRequest; request.Method = "Post"; request.ContentType = "application/x-www-form-urlencoded"; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes(XML); request.ContentLength = data.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) throw new Exception(String.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); Console.ReadKey(); } } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } }} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { try { var XML = "XML=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SMS>\n" + "<operations>\n" + "<operation>GETPRICE</operation>\n" + "</operations>\n" + "<authentification>\n" + "<username></username>\n" + "<password></password>\n" + "</authentification>\n" + "<message>\n" + "<sender>SMS</sender>\n" + "<text>Test message [UTF-8]</text>\n" + "</message>\n" + "<numbers>\n" + "<number messageID=\"msg11\">393333333333</number>\n" + "</numbers>\n" + "</SMS>\n"; HttpWebRequest request = WebRequest.Create("http://www.smsstar.it/account/xml.php") as HttpWebRequest; request.Method = "Post"; request.ContentType = "application/x-www-form-urlencoded"; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes(XML); request.ContentLength = data.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) throw new Exception(String.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); Console.ReadKey(); } } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } }} |
RICEVERE IL SALDO DEI CREDITI A DISPOSIZIONE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { try { var XML = "XML=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SMS>\n" + "<operations>\n" + "<operation>BALANCE</operation>\n" + "</operations>\n" + "<authentification>\n" + "<username></username>\n" + "<password></password>\n" + "</authentification>\n" + "</SMS>\n"; HttpWebRequest request = WebRequest.Create("http://www.smsstar.it/account/xml.php") as HttpWebRequest; request.Method = "Post"; request.ContentType = "application/x-www-form-urlencoded"; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes(XML); request.ContentLength = data.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) throw new Exception(String.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); Console.ReadKey(); } } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } }} |
ESEMPI DI SCRIPT PER INVIARE SMS TRAMITE IL GATEWAY DI SMSSTAR
Script in PHP per Inviare SMS
Script in C# per Inviare SMS
Script in Java per Inviare SMS
Script in Perl per Inviare SMS
Script in Python per Inviare SMS
English
Deutsch
Espanol
Francais
Russian
Ukrainian
Portuguese
Italiano
Turkish
Polish






