The HTTP SMS API allows you to send SMSs worldwide from a webpage, script or software. This solution is particularly adapted to the needs of webmasters, developers or professionals willing to include a strong added value to their projects by integrating freely our SMSs solutions.
Using the HTTP or HTTPS protocol, the SMS API can be integrated in all of your realizations, whatever the language (ASP, C , C++, Deplhi, Java, JSP, PHP, WINDEV, etc…). For this, it is needed to send parameters in GET or POST. For a better use, you will have to choose between the XML or JSON flow transmission.
UTILIZATION PROCESS OF THE HTTP SMS API ON ALLMYSMS.COM
To send SMSs and interact with the API, GET or POST parameters or XML/JSON flows must be transmitted to the platform.
The platform will then automatically send you back another flow of information containing data (codes, login, notifications…).
ADDRESS AND PARAMETERS (GET OR POST)
https://api.allmysms.com/http/9.0/sendSms
The variable containing the flow must be named smsData.
- clientcode : login
- apiKey : API key available on your manager account
- smsData : XML or JSON flow containing the message and the phone numbers
DOCUMENTATION
- Dowload the lastet documentation version of the HTTP SMS API : allmysms_api_https_v9.0_EN.pdf
EXAMPLE
Allmysms.com put at your disposal codes examples so you can use our services faster and easier:
Script d’envoi de SMS en PHP
<?php //config $url = 'https://api.allmysms.com/http/[version]/sendSms/'; $login = 'yourlogin'; //votre identifant allmysms $apiKey = 'yourapikey'; //votre mot de passe allmysms $message = 'Envoi de SMS test avec AllMySMS.com'; //le message SMS, attention pas plus de 160 caractères $sender = 'expediteur'; //l'expediteur, attention pas plus de 11 caractères alphanumériques $msisdn = '33612345678'; //numé©ro de téléphone du destinataire $smsData = "<DATA> <MESSAGE><![CDATA[".$message."]]></MESSAGE> <TPOA>$sender</TPOA> <SMS> <MOBILEPHONE>$msisdn</MOBILEPHONE> </SMS> </DATA>"; $fields = array( 'login' => urlencode($login), 'apiKey' => urlencode($apiKey), 'smsData' => urlencode($smsData), ); $fieldsString = ""; foreach($fields as $key=>$value) { $fieldsString .= $key.'='.$value.'&'; } rtrim($fieldsString, '&'); try { $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); echo $result; curl_close($ch); } catch (Exception $e) { echo 'Api allmysms injoignable ou trop longue a repondre ' . $e->getMessage(); } ?>
Script d’envoi de SMS en dotNet
string url = "https://api.allmysms.com/http/[version]/sendSms/"; string login = "yourlogin"; string apiKey = "yourapikey"; Uri uri = new Uri(url); string data = "login="+login+"&apiKey="+apiKey+"&smsData=<DATA><MESSAGE><![CDATA[envoi de SMS en dotNet avec allmysms.com]]></MESSAGE><TPOA>EXPEDITEUR</TPOA><SMS><MOBILEPHONE>33612345678</MOBILEPHONE></SMS></DATA>"; byte[] Buffer = System.Text.Encoding.UTF8.GetBytes(data); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); request.Method = WebRequestMethods.Http.Post; request.ContentLength = Buffer.Length; request.ContentType = "application/x-www-form-urlencoded"; using (Stream writer = request.GetRequestStream()) { writer.Write(Buffer, 0, Buffer.Length); writer.Flush(); writer.Close(); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string tmp = reader.ReadToEnd(); response.Close(); Response.Write(tmp);
Script d’envoi de SMS en JAVA
import java.io.*; import java.net.*; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; public class sendSms { public static void main(String[] args) throws Exception { String phoneNumber = "33612345678"; String sender = "EXPEDITEUR"; String message = URLEncoder.encode("Envoi de SMS en Java avec allmysms.com STOP au 36180", "UTF-8"); String login = "yourlogin"; String apiKey = "yourapikey"; String smsData = "<DATA><MESSAGE><![CDATA[["+message+"]]></MESSAGE><TPOA>"+sender+"</TPOA><SMS><MOBILEPHONE>"+phoneNumber+"</MOBILEPHONE></SMS></DATA>"; String url = "https://api.allmysms.com/http/[version]/sendSms/?login=" + login + "&apiKey=" + apiKey + "&smsData=" + smsData; // Send GET request URL client = new URL(url); URLConnection conn = client.openConnection(); InputStream responseBody = conn.getInputStream(); // Convert in XML document byte[] contents = new byte[1024]; int bytesRead=0; String strFileContents = null; while( (bytesRead = responseBody.read(contents)) != -1){ strFileContents = new String(contents, 0, bytesRead); } responseBody.close(); System.out.println(strFileContents); } }
Script d’envoi de SMS en WINDEV
sLogin est une chaîne sLogin="yourlogin" sApiKey est une chaîne sApiKey="yourapikey" sUrl est une chaîne sUrl ="https://api.allmysms.com/http/[version]/sendSms/" sFlux est une chaîne sFlux="<DATA><MESSAGE><![CDATA[envoi de SMS en windev avec allmysms.com]]></MESSAGE><TPOA>EXPEDITEUR</TPOA><SMS><MOBILEPHONE>33612345678</MOBILEPHONE></SMS></DATA>" // Paramètres Post sParametrePost est une chaîne sParametrePost=ChaineConstruit("login=%1&apiKey=%2&smsData=%3",sLogin, sApiKey, sFlux) // Requête SI HTTPRequete(sUrl, "", "",sParametrePost)=Vrai ALORS Info("Votre SMS a bien été envoyé") SINON Erreur(ErreurInfo()) FIN
Script d’envoi de SMS en PERL
my $userAgent = new LWP::UserAgent; $userAgent->protocols_allowed( [ 'https'] ); my $request = POST('https://api.allmysms.com/http/[version]/sendSms/', [ 'login' => 'yourlogin', 'apiKey' => 'yourapikey', 'smsData' => '<DATA><MESSAGE><![CDATA[envoi de SMS en perl avec allmysms.com]]></MESSAGE><TPOA>EXPEDITEUR</TPOA><SMS><MOBILEPHONE>33612345678</MOBILEPHONE></SMS></DATA>'], Content_Type => 'multipart/form-data'); my $response = $userAgent->request($request);
Script d’envoi de SMS en PYTHON
import urllib import xml.etree.ElementTree as ET smsData = 'EXPEDITEUR ' urlbase = 'http://api.msinnovations.com/http/sendSms_v8.php' urlparam = urllib.urlencode([('clientcode','yourlogin'),('passcode','yourpasswd'),('smsData',smsData)]) response = ET.parse(urllib.urlopen(urlbase+urlparam)).getroot() print response.findtext('status') 33612345678
Script d’envoi de SMS en RUBY
url = URI.parse('https://api.allmysms.com/http/[version]/sendSms/') req = Net::HTTP::Post.new(url.path) req.set_form_data({'login'=>'yourlogin','apiKey'=>'yourapikey','smsData'=>'<DATA><MESSAGE><![CDATA[envoi de SMS en windev avec allmysms.com]]></MESSAGE><TPOA>EXPEDITEUR</TPOA><SMS><MOBILEPHONE>33612345678</MOBILEPHONE></SMS></DATA>'}, '&') http = Net::HTTP.new(url.host, url.port) http.use_ssl = true res = http.start {|http| http.request(req) }
Script d’envoi de SMS en C#
using System; using System.Net; using System.Xml; namespace TestSendSMS { class TestSendSMS { static void Main(string[] args) { // Init parameters String login = "yourlogin"; String apiKey = "yourapikey"; String smsData = "<DATA><MESSAGE><![CDATA[envoi de SMS en C# avec allmysms.com]]></MESSAGE><TPOA>EXPEDITEUR</TPOA><SMS><MOBILEPHONE>33612345678</MOBILEPHONE></SMS></DATA>"; String url = "https://api.allmysms.com/http/[version]/sendSms/?login=" + login + "&apiKey=" + apiKey + "&smsData=" + smsData; // Send GET request WebClient client = new WebClient(); string result = client.DownloadString(url); Console.WriteLine("Result : " + result); // Parse the returned XML XmlDocument document = new XmlDocument(); document.LoadXml(result); Console.WriteLine("Status code : " + document.GetElementsByTagName("status")[0].InnerText); } } }
Script d’envoi de SMS en VB
Option explicit Const login = "yourlogin" Const apiKey = "yourapikey" Dim smsData smsData = "<DATA><MESSAGE><![CDATA[envoi de SMS en vb avec allmysms.com]]></MESSAGE><TPOA>EXPEDITEUR</TPOA><SMS><MOBILEPHONE>33612345678</MOBILEPHONE></SMS></DATA>" EnvoiSms clientCode,passCode,smsData Sub EnvoiSms(clientCode, passCode, smsData) Dim xmlDoc,stUrl stUrl = "https://api.allmysms.com/http/[version]/sendSms/?login=" & _ login &"&apiKey=" & apiKey & "&smsData=" & Escape(smsData) Set xmlDoc=CreateObject("Microsoft.XMLDOM") xmlDoc.Async="false" if xmlDoc.Load(stUrl) and not xmldOC.selectSingleNode("/") is Nothing Then Msgbox "status = " & xmldOC.selectSingleNode("/").text else MsgBox "Pb sending", vbCritical End if End sub
SMS STATUS AFTER BEING SENT:
100 | The message has been sent |
101 | The message has been programmed for a delayed sending |
102 | Connection problems – We could not match any of the accounts to your clientcode and passcode |
103 | No more credits. Please re-credit your account on AllMySms.com |
104 | Not enough credit. To use: XX Credits, Available: YY Credits. Please re-credit your account on AllMySms.com |
105 | Empty XML flow. |
106 | Invalid or incomplete XML flow. |
107 | The client code given in the XML flow is invalid or incomplete. It needs to be written in capital letters. |
108 | Empty message in the XML flow. |
109 | The message is more than 640 characters. |
110 | XML flow invalid or incomplete. |
111 | Some phone numbers are not valid. |
112 | None of the phone numbers are valid. Please check the online documentation concerning the formats. |
113 | Your link is too long: it has to be less than 80 characters. |
114 | The master account specified does not exist. |
EXAMPLE OF XML FLOWS
<DATA> <MESSAGE><![CDATA[Your Message]]></MESSAGE> <DYNAMIC>2 (will contain the number of variable parameters of the message)</DYNAMIC> (mandatory if the message is variable) <CAMPAIGN_NAME>Name of the Campaign</CAMPAIGN_NAME> (optional) <DATE>Date ex.: 2011-11-05 15:10:00 </DATE> (optional) <TPOA> Sender Name (optional)</TPOA> <MAIL_NOTIF>0 -> no notification, 1 -> notification </MAIL_NOTIF> (optional) <SMS> <MOBILEPHONE>33611111111</MOBILEPHONE> <PARAM_1>Parameter 1</PARAM_1> <PARAM_2>Parameter 2</PARAM_2> </SMS> <SMS> <MOBILEPHONE>33622222222</MOBILEPHONE> <PARAM_1>Parameter 1</PARAM_1> <PARAM_2>Parameter 2</PARAM_2> </SMS> </DATA>
EXAMPLE OF JSON FLOWS
{ "DATA": { "CAMPAIGN_NAME": "Name of the Campaign", "MESSAGE": "Your message", "TPOA": "Sender Name", "DYNAMIC": "2", "DATE": "2014-01-01 12:00:00", "SMS": [ { "MOBILEPHONE": "33611111111", "PARAM_1": "Parameter 1", "PARAM_2": "Parameter 2" }, { "MOBILEPHONE": "33622222222", "PARAM_1": "Parameter 1", "PARAM_2": "Parameter 2" } ] } }