Platform of
A2P mobile messaging

Integrate SMS, TTS, WhatsApp & RCS
to your applications & your communication

Specializing in sending and receiving SMS, TTS, WhatsApp and RCS, our powerful mobile messaging solutions adapt to all your needs. With worldwide coverage by direct operator connection, our CPaaS platform solutions enable users to build applications via our APIs and powerful web services.

MOBILE MESSAGING PLATFORM
A SIMPLE & POWERFUL SERVICE
ADAPTED TO EACH OF YOUR NEEDS

Develop your business with high-performance tools that are constantly improved by our team. They are designed to be intuitive and easy to use to carry out your campaigns to thousands of contacts in just a few clicks!

 

  • Self-service SaaS platform
  • Full functionalities for sending, managing, analyzing, or exporting campaigns
  • Reception statistics provided (DLR), opt'out management

CREATE YOUR FREE ACCOUNT

SMS Sending Platform

INTEGRATION
QUICKLY IMPLEMENT OUR API SMS
USING OUR SDK

Integrate our sending, receiving and authentification features into your
application, site or software, in high quality and in a few minutes. By using our Rest API, you make SMS notifications quickly, reliably, securely, and all around the world.

 

  • Compatible with all programming languages (PHP, Java, ASP, C++, Ruby, WINDEV, etc.)
  • Full SDK and libraries available with snippets of available queries
  • Strong experience in supporting startups
const ERROR_API = "Error during API call\n";
const ERROR_FILE = "The specified file does not exist\n";
const URL = "https://api.smsmode.com/http/1.6/";
const PATH_SEND_SMS = "sendSMS.do";
const PATH_SEND_SMS_BATCH = "sendSMSBatch.do";

/**
*    Function parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

class ExempleClientHttpApi 
{
 // send SMS with GET method
 public function sendSmsGet($accessToken, $message, $destinataires, $emetteur, $optionStop) 
 {
     $message = iconv("UTF-8", "ISO-8859-15", $message);
     $fields_string = '?accessToken='.$accessToken.'&message='.urlencode($message).'&numero='.$destinataires.'&emetteur='.$emetteur.'&stop='.$optionStop;
 
     $ch = curl_init();
     curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch,CURLOPT_URL, URL.PATH_SEND_SMS.$fields_string);
     $result = curl_exec($ch);
     curl_close($ch);
     if (!$result) {
         return ERROR_API;
     }
     return $result;
 }

 // send SMS with POST method
 public function sendSmsPost($accessToken, $message, $destinataires, $emetteur, $optionStop) 
 {
     $message = iconv("UTF-8", "ISO-8859-15", $message);
     $fields_string = 'accessToken='.$accessToken.'&message='.urlencode($message).'&numero='.$destinataires.'&emetteur='.$emetteur.'&stop='.$optionStop;
 
     $ch = curl_init();
     curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch,CURLOPT_URL, URL.PATH_SEND_SMS);
     curl_setopt($ch,CURLOPT_POST, 1);
     curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
     $result = curl_exec($ch);
     curl_close($ch);
     if (!$result) {
         return ERROR_API;
     }
     return $result;
 }

 // send SMS with POST method (Batch)
 public function sendSmsBatch($accessToken, $batchFilePath, $optionStop) 
 {
     if (!file_exists($batchFilePath)) {
         return ERROR_FILE;
     }

     $fields_string = '?accessToken='.$accessToken.'&stop='.$optionStop;
     $cfile = new CurlFile($batchFilePath, 'text/csv');
     $data = array('data-binary' => $cfile);

     $ch = curl_init();
     curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'content-type: multipart/form-data'));
     curl_setopt($ch,CURLOPT_URL, URL.PATH_SEND_SMS_BATCH.$fields_string);
     curl_setopt($ch,CURLOPT_POST, 1);
     curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
     $result = curl_exec($ch);
     curl_close($ch);
     if (!$result) {
         return ERROR_API;
     }
     return $result;
 }
}
const urlencode = require('urlencode');
var exports=module.exports={};
const urlencode = require('urlencode');
const http = require('https');
const querystring = require('querystring');
const fs = require('fs');
const pathname = require("path");
const ERROR_API = "Error during API call";
const ERROR_FILE = "The specified file does not exist";
const HOSTNAME = 'api.smsmode.com'
const PATH_SEND_SMS = "/http/1.6/sendSMS.do";
const PATH_SEND_SMS_Batch = "/http/1.6/sendSMSBatch.do";

/**
*    Function parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

exports.ExempleClientHttpAPI = class {

 // send SMS with GET method
 async sendSmsGet(accessToken, message, destinataires, emetteur, optionStop) {

     var finalPath = PATH_SEND_SMS + '?accessToken=' + accessToken + '&numero=' + destinataires + 
         "&message=" + urlencode(message,'ISO-8859-15') + '&emetteur=' + emetteur + '&stop=' + optionStop;
     const options = {
         hostname: HOSTNAME,
         port: 443,
         path: finalPath,
         method: 'GET'
     };
     try {
         let http_promise = this.getHttpResponse(options, "");
         let response_body = await http_promise;
         return response_body;
     }
     catch(error) {
         return ERROR_API;
     }
 }

 // send SMS with POST method
 async sendSmsPost(accessToken, message, destinataires, emetteur, optionStop) {

     var postData = querystring.stringify({
         'accessToken': accessToken, 
         'numero': destinataires, 
         'emetteur' : emetteur, 
         'stop' : optionStop 
     });
     postData = postData + "&message=" + urlencode(message,'ISO-8859-15');
     const options = {
         hostname: HOSTNAME,
         port: 443,
         path: PATH_SEND_SMS,
         method: 'POST',
         headers: {
             'Content-Type': 'application/x-www-form-urlencoded; charset=ISO-8859-15',
             'Content-Length': Buffer.byteLength(postData)
         }
     };
     try {
         let http_promise = this.getHttpResponse(options, postData);
         let response_body = await http_promise;
         return response_body;
     }
     catch(error) {
         return ERROR_API;
     }
 }

 // send SMS with POST method (Batch)
 async sendSmsBatch(accessToken, batchFilePath, optionStop) {

     var finalPath = PATH_SEND_SMS_Batch + "?accessToken=" + accessToken + "&stop=" + optionStop;
     try {
         let content_file_promise = this.getContentFile(batchFilePath);
         let content = await content_file_promise;
         var boundary = "AaB03x";
         var postData = Buffer.concat([
             Buffer.from("--" + boundary + "\r\n"),
             Buffer.from("Content-Disposition: form-data; name=\"file\"; filename=\""),
             Buffer.from(pathname.basename(batchFilePath) + "\"\r\n"),
             Buffer.from("Content-Type:text/csv\r\n\r\n"),
             Buffer.from(content),
             Buffer.from("\r\n--" + boundary + "--\r\n"),
         ]);
         var options = {
             method: 'POST',
             hostname: HOSTNAME,
             port: 443,
             path: finalPath,
             headers: {
                 "Content-Type": "multipart/form-data; boundary=" + boundary,
                 'Content-Length': Buffer.byteLength(postData)
             }
         };
         try {
         let http_promise = this.getHttpResponse(options, postData);
         let response_body = await http_promise;
         return response_body;
         }
         catch(error) {
             return ERROR_API;
         }
     }
     catch(error) {
         return ERROR_FILE;
     }
 }

 getHttpResponse(options, postData) {
     return new Promise((resolve, reject) => {
         const req = http.request(options, (res) => {
             let chunks_of_data = [];
             res.on('data', (fragments) => {
                 chunks_of_data.push(fragments);
             });
             res.on('end', () => {
                 let response_body = Buffer.concat(chunks_of_data);
                 resolve(response_body.toString());
             });
         });
         req.on('error', (error) => {
             reject(error);
         });
         req.write(postData);
         req.end();
     });
 }

 getContentFile(batchFilePath) {
     return new Promise((resolve, reject) => {
         fs.readFile(batchFilePath, async function(err, content) {
             if (err) {
                 reject(err);
             } else {
                 resolve(content);
             }
         });
     });
 }
}
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.util.EncodingUtil;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
*    Parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

public class ExempleClientHttpAPI {

 private static final String URL = "https://api.smsmode.com/http/1.6/";
 private static final String PATH_SEND_SMS = "sendSMS.do";
 private static final String PATH_SEND_SMS_BATCH = "sendSMSBatch.do";
 private static final String ERROR_FILE = "The specified file does not exist";

 // send SMS with GET method
 public String sendSmsGet(String accessToken, String message, String destinataires, String emetteur, String optionStop) throws IOException {

     HttpClient httpClient = new HttpClient();
     String finalUrl = URL + PATH_SEND_SMS;
     GetMethod httpMethod = new GetMethod(finalUrl);
     httpMethod.addRequestHeader("Content-Type", "plain/text; charset=ISO-8859-15");

     NameValuePair[] params = {
         new NameValuePair("accessToken", accessToken),
         new NameValuePair("message", message),
         new NameValuePair("numero", destinataires),
         new NameValuePair("emetteur", emetteur),
         new NameValuePair("stop", optionStop)
     };

     httpMethod.setQueryString(EncodingUtil.formUrlEncode(params, "ISO-8859-15"));
     httpClient.executeMethod(httpMethod);
     return convertToString(httpMethod.getResponseBodyAsStream()); 
 }

 // send SMS with POST method
 public String sendSmsPost(String accessToken, String message, String destinataires, String emetteur, String optionStop) throws IOException {
     HttpClient httpClient = new HttpClient();
     String finalUrl = URL + PATH_SEND_SMS;
     PostMethod httpMethod = new PostMethod(finalUrl);
     httpMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-15");

     NameValuePair[] params = {
         new NameValuePair("accessToken", accessToken),
         new NameValuePair("message", message),
         new NameValuePair("numero", destinataires),
         new NameValuePair("emetteur", emetteur),
         new NameValuePair("stop", optionStop)
     };

     httpMethod.setRequestBody(params);
     httpClient.executeMethod(httpMethod);
     return convertToString(httpMethod.getResponseBodyAsStream());
 }

 // send SMS with POST method (Batch)
 public String sendSmsBatch(String accessToken, String batchFilePath, String optionStop) throws IOException {
     File file = new File(batchFilePath);
     if (!file.exists())
         return ERROR_FILE;

     HttpClient httpClient = new HttpClient();
     String finalUrl = URL + PATH_SEND_SMS_BATCH + "?accessToken=" + accessToken + "&stop=" + optionStop;
     PostMethod httpMethod = new PostMethod(finalUrl);

     Part[] parts = new Part[1];
     parts[0] = new FilePart(file.getName(), file, "text/csv", null);

     httpMethod.setRequestEntity(new MultipartRequestEntity(parts, httpMethod.getParams()));
     httpClient.executeMethod(httpMethod);
     return convertToString(httpMethod.getResponseBodyAsStream());
 }

 private String convertToString(InputStream stream) {
     Scanner sc = new Scanner(stream);
     StringBuilder sb = new StringBuilder();
     while(sc.hasNext()){
         sb.append(sc.nextLine());
     }
     return sb.toString();
 }
}
import requests
import urllib
import sys
import os.path

ERROR_API = "Error during API call"
ERROR_FILE = "The specified file does not exist"
URL = 'https://api.smsmode.com/http/1.6/'
PATH_SEND_SMS = "sendSMS.do"
PATH_SEND_SMS_BATCH = "sendSMSBatch.do"


"""
*    Function parameters:
*
*    - access_token (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - option_stop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batch_file_path (required for batch mode): The path of CSV file for sms in Batch Mode
"""

class ExempleClientHttpApi:

 # send SMS with GET method
 def send_sms_get(self, access_token, message, destinataires, emetteur, option_stop):

     final_url = (
         URL + PATH_SEND_SMS + 
         '?accessToken=' + access_token + 
         '&message=' + urllib.quote_plus(message.encode('iso-8859-15')) + 
         '&numero=' + destinataires + 
         '&emetteur=' + emetteur + 
         '&stop=' + option_stop
     )
     r = requests.get(final_url)
     if not r:
         return ERROR_API
     return r.text

 # send SMS with POST method
 def send_sms_post(self, access_token, message, destinataires, emetteur, option_stop):

     final_url = URL + PATH_SEND_SMS
     headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
     payload = {
         'accessToken': access_token,
         'message': message,
         'numero': destinataires,
         'emetteur': emetteur,
         'stop': option_stop
     }
     r = requests.post(final_url, data=payload, headers=headers)
     if not r:
         return ERROR_API
     return r.text

 # send SMS with POST method (Batch)
 def send_sms_batch(self, access_token, batch_file_path, option_stop):

     final_url = URL + PATH_SEND_SMS_BATCH + "?accessToken=" + access_token + "&stop=" + option_stop
     if not os.path.isfile(batch_file_path):
         return ERROR_FILE
     r = requests.post(final_url, files={'file': open(batch_file_path,'rb')})
     if not r:
         return ERROR_API
     return r.text
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text;
using System.Web;

/**
*    Function parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

namespace ExempleClientHttpApi
{
 public class ExempleClientHttpApi {

     private static string URL = "https://api.smsmode.com/http/1.6/";
     private static string PATH_SEND_SMS = "sendSMS.do";
     private static string PATH_SEND_SMS_BATCH = "sendSMSBatch.do";
     private static string ERROR_API = "Error during API call\n";
     private static string ERROR_FILE = "The specified file does not exist\n";
     private static readonly HttpClient _httpClient= new HttpClient();
 
     public ExempleClientHttpApi()
     {
         Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
     }

     // send SMS with GET method 
     public string sendSmsGet(string accessToken, string message, string destinataires, string emetteur, string optionStop) { 

         string urlEncodedMessage = HttpUtility.UrlEncode(message, Encoding.GetEncoding("ISO-8859-15"));
         string finalUrl = URL + PATH_SEND_SMS + "?accessToken=" + accessToken + "&numero=" + destinataires + "&message=" + urlEncodedMessage + "&emetteur=" + emetteur + "&stop=" + optionStop;
 
         return Get(finalUrl).Result;
     }

     public static async Task<string> Get(string url){

         try {
             var response = await _httpClient.GetAsync(url);
             string result = await response.Content.ReadAsStringAsync();
             return result;
         } catch (Exception) {
             return ERROR_API;
         }
     }

     // send SMS with POST method 
     public string sendSmsPost(string accessToken, string message, string destinataires, string emetteur, string optionStop) {

         string finalUrl = URL + PATH_SEND_SMS;

         StringBuilder sb = new StringBuilder();
         sb.Append("accessToken=" + accessToken);
         sb.Append("&numero=" + destinataires);
         sb.Append("&emetteur=" + emetteur);
         sb.Append("&message=" + HttpUtility.UrlEncode(message, Encoding.GetEncoding("ISO-8859-15")));
         sb.Append("&stop=" + optionStop);

         return Post(finalUrl ,Encoding.Default.GetBytes(sb.ToString())).Result;
     }

     public static async Task<string> Post(string url, byte[] data){

         ByteArrayContent byteContent = new ByteArrayContent(data);
         byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
         try {
             var response = await _httpClient.PostAsync(url, byteContent);
             string result = await response.Content.ReadAsStringAsync();
             return result;
         } catch (Exception) {
             return ERROR_API;
         }
     }

     // send SMS with POST method (batch)
     public string sendSmsBatch(string accessToken, string batchFilePath, string optionStop) {

         if (!File.Exists(batchFilePath)) {
             return ERROR_FILE;
         }
         string finalUrl = URL + PATH_SEND_SMS_BATCH + "?accessToken=" + accessToken + "&stop=" + optionStop;
         return PostBatch(finalUrl , File.ReadAllBytes(batchFilePath), batchFilePath).Result;
     }

     public static async Task<string> PostBatch(string url, byte[] data, string batchFilePath) {

         var requestContent = new MultipartFormDataContent();
         ByteArrayContent byteContent = new ByteArrayContent(data);
         byteContent.Headers.ContentType = MediaTypeHeaderValue.Parse("text/csv");
         requestContent.Add(byteContent, "file", batchFilePath);
         try {
             var response = await _httpClient.PostAsync(url, requestContent);
             string result = await response.Content.ReadAsStringAsync();
             return result;
         } catch (Exception) {
             return ERROR_API;
         }
     }
 }
}
ResLancement = HTTPRequête("https://api.smsmode.com")
SI ResLancement = Vrai ALORS
 ResCode = HTTPDonneRésultat()
 Info("Code HTML : " + ResCode)
FIN
require 'net/http'
require 'uri'
require 'json'


#    Function parameters:
#
#    - accessToken (required)
#    - message (required)
#    - destinataires (required): Receivers separated by a comma
#    - emetteur (optional): Allows to deal with the sms sender
#    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
#    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode

class ExempleClientHttpApi

 ERROR_FILE = "The specified file does not exist";
 URL = "https://api.smsmode.com/http/1.6/"
 PATH_SEND_SMS = "sendSMS.do"
 PATH_SEND_SMS_BATCH = "sendSMSBatch.do"

 def send_sms_get(access_token, message, destinataires, emetteur, option_stop)

     header = {'Content-Type' => 'plain/text; charset=ISO-8859-15'}
     params = { :accessToken => access_token, :message => message.encode(Encoding::ISO_8859_15), :numero => destinataires, :emetteur => emetteur, :stop => option_stop}

     uri = URI.parse(URL + PATH_SEND_SMS);
     uri.query = URI.encode_www_form(params)

     http = Net::HTTP.new(uri.host,uri.port)
     http.use_ssl = true
     request = Net::HTTP::Get.new(uri.request_uri,header)

     res = http.request(request)
     return res.body
 end

 # send SMS with POST method
 def send_sms_post(access_token, message, destinataires, emetteur, option_stop)

     header = {'Content-Type' => 'application/x-www-form-urlencoded; charset=ISO-8859-15'}
     params = { :accessToken => access_token, :message => message.encode(Encoding::ISO_8859_15), :numero => destinataires, :emetteur => emetteur, :stop => option_stop}
     uri = URI.parse(URL + PATH_SEND_SMS);

     http = Net::HTTP.new(uri.host,uri.port)
     http.use_ssl = true
     request = Net::HTTP::Post.new(uri.request_uri,header)
     request.body = URI.encode_www_form(params)

     res = http.request(request)
     return res.body
 end

 # send SMS with POST method (Batch)
 def send_sms_batch(access_token, batch_file_path, option_stop)

     if !File.file?(batch_file_path)
         return ERROR_FILE
     end 

     boundary = "AaB03x"
     header = {'Content-Type' => "multipart/form-data, boundary=#{boundary}"}
     uri = URI.parse(URL + PATH_SEND_SMS_BATCH + '?accessToken=' + access_token + "&stop=" + option_stop);

     post_body = []
     post_body << "--#{boundary}\r\n"
     post_body << "Content-Disposition: form-data; name=\"datafile\"; filename=\"#{File.basename(batch_file_path)}\"\r\n"
     post_body << "\r\n"
     post_body << File.read(batch_file_path)
     post_body << "\r\n--#{boundary}--\r\n"

     http = Net::HTTP.new(uri.host,uri.port)
     http.use_ssl = true
     request = Net::HTTP::Post.new(uri.request_uri, header)
     request.body = post_body.join

     res = http.request(request)
     return res.body
 end

end
import scalaj.http._
import java.nio.file.{Files, Paths}

/**
*    Function parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

object ExempleClientHttpApi {
 
 var ERROR_FILE = "The specified file does not exist";
 var URL = "https://api.smsmode.com/http/1.6/";
 var PATH_SEND_SMS = "sendSMS.do";
 var PATH_SEND_SMS_BATCH = "sendSMSBatch.do";

 // send SMS with GET method
 def send_sms_get(accessToken:String, message:String, destinataires:String, emetteur:String, optionStop:String) : String = {
     var SendSMSUsingGET = Http(URL + PATH_SEND_SMS)
     .param("accessToken", accessToken)
     .param("message", message)
     .param("numero", destinataires)
     .param("emetteur", emetteur)
     .param("stop", optionStop)
     .charset("ISO-8859-15")
     .asString.body
 
     return SendSMSUsingGET;
 }

 // send SMS with POST method
 def send_sms_post(accessToken:String, message:String, destinataires:String, emetteur:String, optionStop:String) : String = {
     var SendSMSUsingPOST = Http(URL + PATH_SEND_SMS)
     .postForm(
         Seq(
             "accessToken" -> accessToken,
             "message" -> message,
             "numero" -> destinataires,
             "emetteur" -> emetteur,
             "stop" -> optionStop
         )
     )
     .charset("ISO-8859-15")
     .asString.body

     return SendSMSUsingPOST;
 }

 // send SMS with POST method (Batch)
 def send_sms_batch(accessToken:String, batchFilePath:String, optionStop:String) : String = {

     if (!Files.exists(Paths.get(batchFilePath))) {
         return ERROR_FILE;
     }

     var finalUrl : String = URL + PATH_SEND_SMS_BATCH + "?accessToken=" + accessToken + "&stop=" + optionStop;
     var SendSMSUsingPOSTBatch = Http(finalUrl)
     .postMulti(MultiPart("file", Paths.get(batchFilePath).getFileName().toString(), "text/csv", Files.readAllBytes(Paths.get(batchFilePath))))
     .asString.body

     return SendSMSUsingPOSTBatch;
 }
}
#include <iostream>
#include <curl/curl.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

/**
*    Function parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

#define URL "https://api.smsmode.com/http/1.6/";
#define PATH_SEND_SMS "sendSMS.do";
#define PATH_SEND_SMS_BATCH "sendSMSBatch.do";
#define ERROR_API "Error during API call";
#define ERROR_FILE "The specified file does not exist";

using namespace std;

static size_t WriteCallback(char *contents, size_t size, size_t nmemb, void *userp)
{
 ((string*)userp)->append((char*)contents, size * nmemb);
 return size * nmemb;
}

class ExempleClientHttpAPI {

 public:

 // send SMS with GET method
 string sendSmsGet(string accessToken, string message, string destinataires, string emetteur, string optionStop) {

     string finalUrl = URL;
     finalUrl += PATH_SEND_SMS;
     finalUrl += "?accessToken=" + accessToken +
     "&message=" + curl_escape(message.c_str(), message.length()) +
     "&numero=" + destinataires +
     "&emetteur=" + emetteur +
     "&stop=" + optionStop;

     string readBuffer;
     CURL *curl;
     CURLcode res;
     curl = curl_easy_init();
     if(curl) {
         curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str());
         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
         curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
         res = curl_easy_perform(curl);
         if(res != CURLE_OK)
         {
             fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
             return ERROR_API;
         }
         curl_easy_cleanup(curl);
     }
     return readBuffer;
 }

 // send SMS with POST method
 string sendSmsPost(string accessToken, string message, string destinataires, string emetteur, string optionStop) {

     string finalUrl = URL;
     finalUrl += PATH_SEND_SMS;
     string postField = "accessToken=" + accessToken + "&message=" + message +
         "&numero=" + destinataires + "&emetteur=" + emetteur + "&stop=" + optionStop;
 
     string readBuffer;
     CURL *curl;
     CURLcode res;
     curl = curl_easy_init();
     if(curl) {
         curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str());
         curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postField.c_str());
         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
         curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
         res = curl_easy_perform(curl);
         if(res != CURLE_OK)
         {
             fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
             return ERROR_API;
         }
         curl_easy_cleanup(curl);
     }
     return readBuffer;
 }

 // send SMS with POST method (Batch)
 string sendSmsBatch(string accessToken, string batchFilePath, string optionStop)
 {
     if(access(batchFilePath.c_str(), F_OK) == -1)
         return ERROR_FILE; 
     string finalUrl = URL;
     finalUrl += PATH_SEND_SMS_BATCH;
     finalUrl += "?accessToken=" + accessToken + 
         "&stop=" + optionStop;
     struct curl_httppost *formpost=NULL;
     struct curl_httppost *lastptr=NULL;
     string readBuffer;
     CURL *curl;
     CURLcode res;
     curl = curl_easy_init();
     if(curl) {
         curl_formadd(&formpost,
             &lastptr,
             CURLFORM_COPYNAME, "sendfile",
             CURLFORM_FILE, batchFilePath.c_str(),
             CURLFORM_END);

         curl_formadd(&formpost,
             &lastptr,
             CURLFORM_COPYNAME, "filename",
             CURLFORM_COPYCONTENTS, batchFilePath.c_str(),
             CURLFORM_END);

         curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str());
         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
         curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
         curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
         res = curl_easy_perform(curl);
         if(res != CURLE_OK)
         {
             fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
             return ERROR_API;
         }
     }
     curl_easy_cleanup(curl);
     return readBuffer;
 }
};

BENEFITS & GUARANTEES
TEST THE DIFFERENCE SMSMODE© !

4Million requests
APIs processed per day

Sending SMS in direct connection (0-HOP)A live routing operators
As French Telecom operator

10000Guided customers
Since 2004

Data protectionConfidentiality
of your sendings

secured by encryption
of your data

Close to our customersAccount management & engineering support
with dedicated interlocutors and
resources, including high-level SLA (Service Level Agreement)

Support 24/7A 24/7 support service
including a reagent
tickets management system

French Tech MemberCPaaS platform
French

member of French Tech, MMAF and GSMA

Need more info?
Contact us!