Spedizione in lotti
- Home
- Spedizione in lotti
Invio di messaggi SMS
Questa richiesta viene utilizzata per inviare messaggi SMS in lotti di 500 in tempo reale o in ritardo.
URL
POST https://api.smspartner.fr/v1/bulk-send
Impostazioni
Ogni richiesta API supporta i seguenti parametri :
- La piattaforma non invia SMS commerciali tra le 22.00 e le 8.00 nei giorni feriali e nelle domeniche e nei giorni festivi (restrizione legale). In caso di invio, i messaggi SMS vengono messi in pausa fino al giorno lavorativo successivo alle 8 del mattino.
- Se non inviate messaggi SMS commerciali, vi preghiamo di contattarci : help@smspartner.fr
apiKey | API key per il tuo account. Lo ottieni nel tuo account Partner SMS |
---|---|
SMSList |
phoneNumber: Numeri di telefono del destinatario. message: Contenuto dell’SMS. Massimo 160 caratteri per SMS (un SMS aggiuntivo ogni 153 caratteri sarà detratto per ogni carattere aggiuntivo). Si prega di notare che alcuni caratteri speciali e caratteri accentati saranno sostituiti quando si invia il messaggio:
|
Parametri opzionali | |
gamme | Gamma dell’SMS, il suo valore deve essere:
Se questa impostazione viene omessa, l’SMS verrà inviato nell’intervallo Premium. |
sender | Nome del mittente del messaggio. Se il mittente viene lasciato vuoto, i vostri messaggi SMS verranno inoltrati con un shortcode operatore come mittente (esempio: 36xxx).
Il numero di caratteri per il nome del mittente deve essere compreso tra 3 e 11 inclus e non deve contenere caratteri speciali. |
scheduledDeliveryDate | La data di invio dell’SMS, nel formato dd/mm/YYYY . Da impostare solo se si desidera che l’SMS venga inviato in ritardo. |
time | Time in cui viene inviato l’SMS (formato 0-24), obbligatorio se è definito scheduledDeliveryDate . |
minute | Minuto di invio dell’SMS (formato 0-55, a intervalli di cinque minuti). Obbligatorio se è impostato scheduledDeliveryDate . |
isStopSms | Gamma Premium: 1 per aggiungere STOP alla fine dell’SMS (obbligatorio per gli SMS commerciali).
Gamme lowcost : Questo parametro non è applicabile per questo range, è necessario aggiungere manualmente la menzione NoPub=STOP per gli SMS commerciali. |
sandbox | Per testare l’invio di SMS, è possibile utilizzare il parametro sandbox :
Non verrà inviato alcun SMS e non ci sarà alcun addebito sul vostro conto. |
_format | Formato della risposta. È possibile scegliere traJSON o XML . Il formato di risposta predefinito è JSON . |
apiKey | La chiave API del vostro conto. Si ottiene nel vostro account Partner SMS. |
---|---|
phoneNumbers | Numeri di telefono dei destinatari Quando si inviano più messaggi SMS, i numeri devono essere separati da virgole.. Possono essere :
|
message | Contenuto dell’SMS. 160 caratteri al massimo per SMS (oltre a questo, vi verrà addebitato un ulteriore SMS per 153 caratteri).
Si prega di notare che alcuni caratteri speciali e caratteri accentati saranno sostituiti al momento dell’invio :
|
Parametri opzionali | |
gamme | Gamma dell’SMS, il suo valore deve essere:
Se questa impostazione viene omessa, l’SMS verrà inviato nell’intervallo Premium. |
sender | Nome del mittente del messaggio. Se il mittente viene lasciato vuoto, i vostri messaggi SMS verranno inoltrati con un codice operatore come mittente (esempio: 36xxx).
Il numero di caratteri per il nome del mittente deve essere compreso tra 3 e 11 e non deve contenere caratteri speciali. |
scheduledDeliveryDate | La data di invio dell’SMS, dd/mm/YYYY . Da impostare solo se si desidera che l’SMS venga inviato in ritardo. |
time | Time in cui viene inviato l’SMS (formato 0-24), obbligatorio se è definitoscheduledDeliveryDate . |
minute | Minuto di invio dell’SMS (formato 0-55, a intervalli di cinque minuti). , obbligatorio se è impostato scheduledDeliveryDate . |
isStopSms | Gamma Premium: 1 per aggiungere STOP alla fine dell’SMS (obbligatorio per gli SMS commerciali).
Gamme lowcost: Questo parametro non è applicabile per questo range, è necessario aggiungere manualmente la menzione NoPub=STOP per gli SMS commerciali. |
sandbox | Per testare l’invio di SMS, è possibile utilizzare il parametrosandbox :
Non verrà inviato alcun SMS e non ci sarà alcun addebito sul vostro conto. Questi messaggi SMS saranno cancellati automaticamente ogni giorno dalle vostre mailing list. |
_format | Formato della risposta. È possibile scegliere tra JSON ou XML . Il formato di risposta predefinito è JSON . |
Richiesta
Interrogazione campione :
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 |
<?php // Prepare data for POST request $fields = array( 'apiKey'=> 'YOUR API KEY', 'sender' => 'mycompany', 'scheduledDeliveryDate'=> '21/10/2014', 'time'=> 9, 'minute'=> 0, 'SMSList'=> array( array( 'phoneNumber'=> '06xxxxxxx1', 'message'=> 'msg 0' ), array( 'phoneNumber'=> '06xxxxxxx2', 'message'=> 'msg 1' ) ) ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/bulk-send'); 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 60 |
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 & "bulk-send" #note : utiliser une librairie JSON en production, par exemple : #https//www.nuget.org/packages/Newtonsoft.Json/ Dim parameters As String = String.Format( "{{""apiKey"":""{0}"",""sender"":""{1}"",""SMSList"":""{2}""}}", apiKey, "mycompany", {{ ""phoneNumber"":"06xxxxxxx1",""message"":"msg1"},{ ""phoneNumber"":"06xxxxxxx2",""message"":"msg2"}} ) 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 30 31 |
# 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_numbers, msg, sender = "SMSPartner"): #sender = "DEMOSMS" print(phone_numbers) data = {"apiKey":APIKEY,"sender":sender,"SMSList":[{"phoneNumber":"06xxxxxxx1","message":"msg1"},{"phoneNumber":"06xxxxxxx2","message":"msg2"}]} url = URL + "/bulk-send" 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 -H "Content-Type: application/json" -X POST -d '{"apiKey":"xxxxx","phoneNumber":"xxxx","message":"test","sender":"mycompany"}' https://api.smspartner.fr/v1/send |
Risposte
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "success": true, "code": 200, "message_id": xxxxxx, "currency": "EUR", "cost": 0.076, "nbSMS": 2, "SMSResponse_List": [ { "success": true, "code": 200, "nbSms": 1, "cost": 0.038, "phoneNumber": "+336xxxxxxx1" }, { "success": true, "code": 200, "nbSms": 1, "cost": 0.038, "phoneNumber": "+336xxxxxxx2" } ] |
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 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>true</entry> <entry>200</entry> <entry>xxxxxx</entry> <entry> <![CDATA[EUR]]> </entry> <entry>0.076</entry> <entry>2</entry> <entry> <entry> <entry>true</entry> <entry>200</entry> <entry>1</entry> <entry>0.038</entry> <entry> <![CDATA[+336xxxxxxx1]]> </entry> </entry> <entry> <entry>true</entry> <entry>200</entry> <entry>1</entry> <entry>0.038</entry> <entry> <![CDATA[+336xxxxxxx2]]> </entry> </entry> </entry> </result> |
Errori
Esempio di messaggio di errore:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "success": false, "code":9, "error": [{ "elementId": "children[message].data", "message": "Le message est requis" }, { "elementId": "children[phoneNumber].data", "message": "Ce numero de telephone n'est pas valide (922264)" }, { "elementId": "children[sender].data", "message": "L'emetteur ne peut pas etre plus long que 11 caracteres" }, { "elementId": "children[scheduledDeliveryDate].data", "message": "La date (21/11/2014 \u00e0 :) est anterieure a la date actuelle." }, { "elementId": "children[minute].data", "message": "La minute est requise" }, { "elementId": "children[time].data", "message": "L'heure est requise" }] } |
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 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>false</entry> <entry>9</entry> <entry> <entry> <entry>children[message].data</entry> <entry>Le message est requis</entry> </entry> <entry> <entry>children[phoneNumber].data</entry> <entry>Ce numéro de téléphone n'est pas valide (922264)</entry> </entry> <entry> <entry>children[sender].data</entry> <entry>L'émetteur ne peut pas être plus long que 11 caractères</entry> </entry> <entry> <entry>children[scheduledDeliveryDate].data</entry> <entry>La date (21/11/2014 à :) est anterieure à la date actuelle. Si vous souhaitez l'envoyer maintenant vous devez sélectionner [Envoi immédiat]</entry> </entry> <entry> <entry>children[minute].data</entry> <entry>La minute est requise</entry> </entry> <entry> <entry>children[time].data</entry> <entry>L'heure est requise</entry> </entry> </entry> </result> |
Codice di controllo
Codice di errore | ||
---|---|---|
1 | La chiave API è richiesta | |
2 | Il numero di telefono è obbligatorio | |
9 | Almeno un vincolo non è stato rispettato durante l’invio :
|
|
10 | Chiave API errata | |
11 | Mancanza di credito |