Supprimer un numéro
- Home
- Supprimer un numéro
Supprimer un numéro de la liste des stops
Cette requête permet de supprimer un numéro de la liste des stops.
URL
GET https://api.smspartner.fr/v1/stop-sms/delete
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. |
---|---|
id | ID du numéro à supprimer. Il se trouve dans la réponse lors de la récupération de la liste des stops. |
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&id=666'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/stop-sms/delete?'.$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 id As Integer = XXX #check credits Dim url As String url = base_url & "stop-sms/delete" & "?apiKey=" & apiKey & "&id=" & id 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 del_stop(self,id): url = URL + "/stop-sms/delete?apiKey=" + API_KEY + "&id=" + id 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/delete?apiKey=xxx&id=300 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
const https = require('https'); let data = 'apiKey=your-api-key&id=333'; let url = 'https://api.smspartner.fr/v1/stop-sms/delete?' + 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 StopSmsDeleteList { public static void main(String[] args) { try { // Prepare data for GET request String apiKey = "YOUR_API_KEY"; String id = "666"; // Create GET request URL String urlString = "https://api.smspartner.fr/v1/stop-sms/delete?" + "apiKey=" + apiKey + "&id=" + id; // 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 StopSmsDeleteList: View { @State private var result: String = "Loading..." var body: some View { VStack { Text("Stop Sms Delete") .font(.title) .padding() Text(result) .font(.system(size: 20)) .padding() } .onAppear(perform: deleteStopSms) } func deleteStopSms() { let apiKey = "YOUR_API_KEY" let id = "666" let urlString = "https://api.smspartner.fr/v1/stop-sms/delete?apiKey=\(apiKey)&id=\(id)" 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 |
package main import ( "io/ioutil" "log" "net/http" "time" ) func main() { // Prepare data for GET request apiKey := "YOUR_API_KEY" id := "666" // Create HTTP client with timeout client := &http.Client{Timeout: 10 * time.Second} // Create GET request URL url := "https://api.smspartner.fr/v1/stop-sms/delete?apiKey=" + apiKey + "&id=" + id // Send GET request resp, err := client.Get(url) if err != nil { log.Fatalf("Error sending request: %v", err) } defer resp.Body.Close() // Process your response here body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response: %v", err) } 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 = "VOTRE_CLÉ_API"; var id = "666"; var uri = new Uri($"https://api.smspartner.fr/v1/stop-sms/delete?apiKey={apiKey}&id={id}"); HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); } else { Console.WriteLine("La demande GET a échoué avec le code d'état : " + response.StatusCode); } } } |
Réponses
1 2 3 4 |
{ "success": true, "code":200 } |
1 2 3 4 5 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>true</entry> <entry>200</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 |
<?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 | |
2 | Le numéro de téléphone est requis | |
3 | L’ID du numéro de téléphone est requis | |
4 | L’ID du numéro de téléphone est introuvable | |
10 | Clé API incorrecte | |
200 | Tout s’est bien passé ! |
© 2014 - 2023 NDA MEDIA. Tous droits réservés. Mentions légales