Liste des stops
- Home
- Liste des stops
Liste des Stops
Cette requête permet de récupérer la liste des numéros qui ont envoyé un stop.
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/stop-sms/list
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 |
---|---|
Paramètres optionnels | |
_format | Format de la réponse. Vous pouvez choisir entre JSON ou XML . Par défaut, le format de réponse est JSON . |
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'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/stop-sms/list?'.$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 56 |
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 phoneNumber As String = "06XXXXXXXX" Dim messageId As Integer = XXX #check credits Dim url As String url = base_url & "stop-sms/list" & "?apiKey=" & apiKey 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_list_stop(self): url = URL + "/stop-sms/list?apiKey=" + API_KEY 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/stop-sms/list?apiKey=xxx |
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 |
const https = require('https'); const apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; const options = { hostname: 'api.smspartner.fr', port: 443, path: `/v1/stop-sms/list?apiKey=${apiKey}`, method: 'GET', }; const req = https.request(options, (res) => { console.log(`statusCode: ${res.statusCode}`); let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }); res.on('end', () => { try { const parsedData = JSON.parse(rawData); // Process your response here console.log(parsedData); } catch (e) { console.error(e.message); } }); }); req.on('error', (error) => { console.error(error); }); req.end(); |
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 |
import java.net.HttpURLConnection; import java.net.URL; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.stream.Collectors; import org.json.JSONObject; public class StopSMSList { public static void main(String[] args) { try { String apiKey = "YOUR_API_KEY"; URL url = new URL("https://api.smspartner.fr/v1/stop-sms/list?apiKey=" + apiKey); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("cache-control", "no-cache"); // Reading API response BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String response = br.lines().collect(Collectors.joining()); // Parse JSON response JSONObject jsonResponse = new JSONObject(response); // Display the JSON response System.out.println(jsonResponse.toString(2)); // Closing HTTP connection conn.disconnect(); } 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 43 44 45 46 47 48 49 50 51 52 53 54 |
import SwiftUI // Structure pour la vue "ListStopSMS" struct ListStopSMS: View { var body: some View { // Un bouton qui appelle la fonction ListStopSMS() lorsqu'il est pressé Button(action: { ListStopSMS() }) { Text("Check Stop SMS List") .font(.system(size: 20)) .foregroundColor(.white) .frame(minWidth: 0, maxWidth: .infinity) .padding() .background(LinearGradient(gradient: Gradient(colors: [Color.blue, Color.blue.opacity(0.8)]), startPoint: .top, endPoint: .bottom)) .cornerRadius(10) .padding(.horizontal) } } // Fonction pour récupérer la liste des SMS stoppés func ListStopSMS() { let apiKey = "XXXXXXXXXXXX YOUR API KEY XXXXXXXXXXXXX" // Votre clé API let urlString = "https://api.smspartner.fr/v1/stop-sms/list?apiKey=\(apiKey)" // URL pour récupérer la liste des SMS stoppés // On vérifie que l'URL est correctement formée guard let url = URL(string: urlString) else { print("URL invalide") return } // Tâche pour récupérer les données de l'URL let task = URLSession.shared.dataTask(with: url) { (data, response, error) in // Si une erreur survient, on l'affiche if let error = error { print("Erreur : \(error)") } // Sinon, on affiche les données reçues else if let data = data { let str = String(data: data, encoding: .utf8) print("Données reçues :\n\(str ?? "")") } } task.resume() // On lance la tâche } } // Aperçu de la vue struct StopSMSList_Previews: PreviewProvider { static var previews: some View { ListStopSMS() } } |
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 |
package main import ( "io/ioutil" "log" "net/http" "time" ) func main() { // Prepare data for GET request apiKey := "YOUR_API_KEY" // Create GET request URL url := "https://api.smspartner.fr/v1/stop-sms/list?" + "apiKey=" + apiKey // 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 |
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 = "VOTRE_CLÉ_API"; var uri = new Uri($"https://api.smspartner.fr/v1/stop-sms/list?apiKey={apiKey}"); HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); } else { Console.WriteLine("La requête GET a échoué avec le code de statut: " + response.StatusCode); } } } |
Réponses
1 2 3 4 5 6 7 8 9 10 11 12 |
{ "success": true, "code": 200, "nbData": 1, "data": [ { "id": 19, "phoneNumber": "+33xxxxxxxxx", "createdAt": "2015-07-20 10:19:45" } ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0" encoding="UTF-8"?> <result> <entry>true</entry> <entry>200</entry> <entry>3</entry> <entry> <entry> <entry>19</entry> <entry> <![CDATA[+33xxxxxxxxx]]> </entry> <entry> <![CDATA[2015-07-20 10:19:45]]> </entry> </entry> </entry> </result> |
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 7 8 |
<?xml version="1.0" encoding="UTF-8"?> <result> <entry>false</entry> <entry>10</entry> <entry> <![CDATA[Clé API incorrecte]]> </entry> </result> |
Code de contrôle
Réponse | ||
---|---|---|
1 | La Clé API est requise | |
10 | Clé API incorrecte | |
200 | Tout s’est bien passé ! |
© 2014 - 2023 NDA MEDIA. Tous droits réservés. Mentions légales