Statut multiple
- Home
- Statut multiple
Statut de remise
Cette requête permet de récupérer le statut de plusieurs SMS (maximum 500 numéros).
A noter : les comptes-rendus sont reçus en moyenne quelques secondes après l’envoi du SMS ; cependant, ce délai peut s’étendre jusqu’à 48h maximum selon les opérateurs et la charge de notre plateforme.
URL
POST https://api.smspartner.fr/v1/multi-status
Paramètres
Chaque demande d’API prend en charge les paramètres suivants :
apiKey | Clé API de votre compte. Vous l’obtenez dans votre compte SMS Partner |
---|---|
SMSStatut_List |
phoneNumber: Numéros de téléphone des destinataires. messageId: ID du message. |
Attention !! Il n’est pas possible d’annuler l’envoi d’un SMS moins de 5 minutes avant son envoi.
Requête
Exemple de requête :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php // Prepare data for POST request $fields = array( 'apiKey'=> 'YOUR API KEY', 'SMSStatut_List'=>>array( array('phoneNumber'=>'+336xxxxxxxx','messageId'=>messageId1), array('phoneNumber'=>'+336xxxxxxxx','messageId'=>messageId2) ) ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/multi-status'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($fields)); $result = curl_exec($curl); curl_close($curl); // Process your response here echo $result; ?> |
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 |
Imports System.IO Imports System.Net Module Module1 Sub Main() Dim base_url As String = "http://api.smspartner.fr/v1/" Dim apiKey As String = "VOTRE_APIKEY" #send sms url = base_url & "multi-status" #note : utiliser une librairie JSON en production, par exemple : #https//www.nuget.org/packages/Newtonsoft.Json/ Dim parameters As String = String.Format( "{{""apiKey"":""{0}"",""SMSStatut_List"":""{1}""}}", apiKey, {{ ""phoneNumber"":"06xxxxxxx1",""messageId"":"msgId1"},{ ""phoneNumber"":"06xxxxxxx2",""message"":"msgId2"}} ) Console.Write(parameters) apiRequest("POST", url, parameters) End Sub Function apiRequest(method As String, url As String, parameters As String) As String Dim request As HttpWebRequest request = WebRequest.Create(url) request.Method = method request.Timeout = 10000 # timeout in ms request.ContentType = "application/json; charset=utf-8" request.ContentLength = 0 #set POST data If Not String.IsNullOrEmpty(parameters) Then request.ContentLength = parameters.Length Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream()) reqStream.Write(parameters) End Using End If #get response Dim returnValue As String = Nothing Using response As HttpWebResponse = request.GetResponse() If response.StatusCode = HttpStatusCode.OK Then Using resStream = response.GetResponseStream() If resStream IsNot Nothing Then Using reader As New StreamReader(resStream) returnValue = reader.ReadToEnd() End Using End If End Using End If End Using apiRequest = returnValue End Function End Module |
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 |
# std import logging import json from collections import OrderedDict # 3p import requests API_KEY = "MY API KEY" URL = "https://api.smspartner.fr/v1" class SMSPartner(): def send_sms(self,phone_number, phone_number2, msgId1, msgId2): print(phone_number) data = {"apiKey":APIKEY,"SMSStatut_List":[{"phoneNumber":phone_number,"messageId":msgId1},{"phoneNumber":phone_number2,"messageId":msgId2}]} url = URL + "/multi-status" r = requests.post(url, data=json.dumps(data), verify=False) r_json = r.json() if r_json.get("success") == True: print(r_json) status = True else: print("SMS msg {} not delivered to {}".format(msg, phone_numbers)) status = False return status |
1 |
curl -X POST https://api.smspartner.fr/v1/multi-status -H "Content-Type: application/json" -d '{"apiKey": "Votre clé API","SMSStatut_List": [{"phoneNumber": "0619922264", "messageId": 199897},{"phoneNumber": "06xxxxxxx2", "messageId": 1000},{"phoneNumber": "06xxxxxxx1", "messageId": 1222}]}' |
Réponses
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 |
{ "success": true, "code": 200, "StatutResponse_List": [ { "success": true, "code": 200, "phoneNumber": "+33699999993", "messageId": 111111, "status": "Delivered", "date": "1517934416", "stopSms": "0", "isSpam": "0" }, { "success": false, "code": 4, "phoneNumber": "+33699999992", "messageId": 1000, "status": "Numéro introuvable" }, { "success": false, "code": 4, "phoneNumber": "+33699999991", "messageId": 1222, "status": "Numéro introuvable" } ] } |
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 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>true</entry> <entry>200</entry> <entry> <entry> <entry>true</entry> <entry>200</entry> <entry> <![CDATA[+33619922264]]> </entry> <entry>1226613</entry> <entry> <![CDATA[Delivered]]> </entry> <entry> <![CDATA[1517934416]]> </entry> <entry> <![CDATA[0]]> </entry> <entry> <![CDATA[0]]> </entry> </entry> <entry> <entry>false</entry> <entry>4</entry> <entry> <![CDATA[+33699999992]]> </entry> <entry>1000</entry> <entry> <![CDATA[Numéro introuvable]]> </entry> </entry> <entry> <entry>false</entry> <entry>4</entry> <entry> <![CDATA[+33699999991]]> </entry> <entry>1222</entry> <entry> <![CDATA[Numéro introuvable]]> </entry> </entry> </entry> </result> |
3 statuts de remises possibles
- Delivered
- Not delivered
- Waiting
Erreurs
Exemple de message d’erreur :
1 2 3 4 5 |
{ "success": false, "code": 10, "message": "Clef API incorrecte" } |
1 2 3 4 5 6 7 8 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>false</entry> <entry>10</entry> <entry> <![CDATA[Clef API incorrecte]]> </entry> </result> |
Code de contrôle
Code erreurs | ||
---|---|---|
1 | La Clé API est requise | |
4 | Numéro introuvable | |
10 | Clé API incorrecte |
© 2014 - 2023 NDA MEDIA. Tous droits réservés. Mentions légales