Estado múltiple
- Home
- Estado múltiple
Estado de entrega
Esta solicitud recupera el estado de varios mensajes SMS. (500 números máximo)
Nota: los informes se reciben en promedio unos segundos después de enviar el SMS; sin embargo, este período puede extenderse hasta 48 horas como máximo en función del operador y la carga en nuestra plataforma.
URL
POST https://api.smspartner.fr/v1/multi-status
Configuraciones
Cada solicitud de API es compatible con los siguientes parámetros :/p>
apiKey | Clave de API de su cuenta. Usted lo consigue en su Cuenta de SMS Partner |
---|---|
SMSStatut_List |
phoneNumber: Los números de teléfono del destinatario. messageId: ID del mensaje. |
¡Atención! No es posible cancelar el envío de un SMS a 5 minutos antes de enviar
Solicitud
Ejemplo de solicitud:
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}]}' |
Respuestas
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> |
Errores
Ejemplo mensaje de error:
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> |
Código de control
Código de error | ||
---|---|---|
1 | Se requiere la clave de la API | |
4 | Número no encontrado | |
10 | Clave de API no válido |