Statut par tag
- Home
- Statut par tag
Statut par Tag
Cette requête permet de récupérer les statuts de plusieurs SMS à partir d’un Tag.
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
GET https://api.smspartner.fr/v1/bulk-status-by-tag
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 |
---|---|
tag | Le tag du message. |
Requête
Exemple de requête :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php // Prepare data for GET request $data = 'apiKey=YOUR_API_KEY&tag=montag'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/bulk-status-by-tag?'.$data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $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 |
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" Dim tag As String = "montag" #check credits Dim url As String url = base_url & "bulk-status-by-tag" & "?apiKey=" & apiKey & "&tag=" & tag Dim credits As String credits = apiRequest("GET", url, Nothing) 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 |
# 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 get_delivery(self,tag): url = URL + "/bulk-status-by-tag?apiKey=" + API_KEY + "&tag=" + tag r = requests.get(url) r_json = r.json() if r_json.get("success") == True: print(r_json) status = True else: print(r_json) status = False return status |
1 |
curl -H "Content-Type: application/json" -X GET https://api.smspartner.fr/v1/bulk-status-by-tag?apiKey=xxx&tag=montag |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const https = require('https'); //Cette requête permet de récupérer les statuts de plusieurs SMS à partir d’un tag. let data = 'apiKey=YOUR_API_KEY&tag=montag'; let url = 'https://api.smspartner.fr/v1/bulk-status-by-tag?' + data; https.get(url, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(JSON.parse(data)); }); }).on("error", (err) => { console.log("Erreur: " + err.message); }); |
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 |
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class StatutParTag { public static void main(String[] args) { try { // Prepare data for GET request String apiKey = "YOUR_API_KEY"; String tag = "montag"; // Create GET request URL String urlString = "https://api.smspartner.fr/v1/bulk-status-by-tag?" + "apiKey=" + apiKey + "&tag=" + tag; // Create URL object URL url = new URL(urlString); // Create HTTP connection HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); // Send GET request int responseCode = connection.getResponseCode(); // Get response BufferedReader reader; if (responseCode >= 200 && responseCode <= 299) { reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); } else { reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); } StringBuilder response = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); // Process your response here System.out.println(response.toString()); } catch (Exception e) { e.printStackTrace(); } } } |
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 |
import SwiftUI struct StatutSmsParTag: View { @State private var result: String = "Loading..." var body: some View { VStack { Text("Statut Sms Par Tag") .font(.title) .padding() Text(result) .font(.system(size: 20)) .padding() } .onAppear(perform: getStatusByTag) } func getStatusByTag() { let apiKey = "YOUR_API_KEY" let tag = "montag" let urlString = "https://api.smspartner.fr/v1/bulk-status-by-tag?apiKey=\(apiKey)&tag=\(tag)" guard let url = URL(string: urlString) else { print("URL inválida") return } let task = URLSession.shared.dataTask(with: url) { (data, response, error) in if let error = error { print("Error: \(error)") } else if let data = data { let result = String(data: data, encoding: .utf8) DispatchQueue.main.async { self.result = result ?? "Error" } } } task.resume() } } |
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 |
package main import ( "io/ioutil" "log" "net/http" "time" ) func main() { // Prepare data for GET request apiKey := "YOUR_API_KEY" tag := "montag" // Create GET request URL url := "https://api.smspartner.fr/v1/bulk-status-by-tag?" + "apiKey=" + apiKey + "&tag=" + tag // Create HTTP client client := &http.Client{Timeout: 10 * time.Second} // Send GET request resp, err := client.Get(url) if err != nil { log.Fatalf("Error sending request: %v", err) } defer resp.Body.Close() // Get response body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } // Process your response here log.Printf("Response: %s", body) } |
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 |
using System; using System.Net.Http; using System.Threading.Tasks; class Program { private static readonly HttpClient client = new HttpClient(); static async Task Main(string[] args) { var apiKey = "YOUR_API_KEY"; var tag = "montag"; var uri = new Uri($"https://api.smspartner.fr/v1/bulk-status-by-tag?apiKey={apiKey}&tag={tag}"); HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); } else { Console.WriteLine("GET request failed with status code: " + response.StatusCode); } } } |
Réponses
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{ "success": true, "code": 200, "currentPage": 1, "total": 2, "StatutResponse_List": [ { "phoneNumber": "+336XXXXXXX1", "status": "Delivered", "stopSMS": false, "date": "1517989111" }, { "phoneNumber": "+336XXXXXXX2", "status": "Delivered", "stopSMS": false, "date": "1517989101" } ... } |
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 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>true</entry> <entry>200</entry> <entry>1</entry> <entry>2</entry> <entry> <entry> <entry> <![CDATA[+336XXXXXXX1]]> </entry> <entry> <![CDATA[Delivered]]> </entry> <entry>false</entry> <entry> <![CDATA[1517989111]]> </entry> </entry> <entry> <entry> <![CDATA[+336XXXXXXX2]]> </entry> <entry> <![CDATA[Delivered]]> </entry> <entry>false</entry> <entry> <![CDATA[1517989086]]> </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": "Clé API incorrecte" } |
1 2 3 4 5 6 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>false</entry> <entry>10</entry> <entry>Clé API incorrecte</entry> </result> |
Code de contrôle
Réponse | ||
---|---|---|
1 | La Clé API est requise | |
3 | L’ID du message est requis | |
4 | Message introuvable | |
10 | Clé API incorrecte | |
200 | Tout s’est bien passé ! |
© 2014 - 2023 NDA MEDIA. Tous droits réservés. Mentions légales