Elenco dei sottoconti
- Home
- Elenco dei sottoconti
Recupero di sottoconti
Ci sono due metodi per recuperare informazioni dai sottoconti:
- Attraverso la piattaforma:
Accedendo al vostro cruscotto avrete accesso a tutti i sottoconti associati al vostro conto.- Dall’API:
Facendo una richiesta sull’url qui sotto.
URL
GET https://api.smspartner.fr/v1/subaccount/list
Impostazioni
Ogni richiesta PLC supporta i seguenti parametri :
apiKey | API key per il tuo account. Lo ottieni nel tuo account Partner SMS |
---|---|
page | Il numero di pagina, ci sono 20 risultati per pagina. Se questo parametro viene omesso, viene restituita la pagina 1. |
Parametri opzionali | |
_format | Formato della risposta. È possibile scegliere tra JSON o XML . Per impostazione predefinita, il formato di risposta è JSON . |
Richiesta
Interrogazione campione :
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/subaccount/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 |
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" #check credits Dim url As String url = base_url & "subaccount/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_subaccount(self): url = URL + "/subaccount/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/subaccount/list?apiKey=xxx&page=1 |
Risposte
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 |
{ "success": true, "code": 200, "total": 29, "nb_per_page": 20, "page": 1, "data": [ { "id": 1, "email": "email1", "type": "simple", "token": "token1", //Est utilisé comme identifiant du sous-compte pour ajouter des crédits "apiKey": "ApiKey sous compte", "createdAt": "2016-03-04 11:23:14", "credits": { "balance": "0.800", "currency": "EUR" } }, { "id": 2, "email": "email2", "type": "simple", "token": "token2", "apiKey": "ApiKey2 du sous compte", "createdAt": "2016-03-04 11:23:14", "credits": { "balance": "10.245", "currency": "EUR" } } ] } |
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 |
<?xml version="1.0" encoding="UTF-8"?> <entry>true</entry> <entry>200</entry> <entry>20</entry> <entry>1</entry> <entry>2</entry> <entry> <entry> <entry>1</entry> <entry> <![CDATA[email1]]> </entry> <entry> <![CDATA[2016-03-04 11:23:14]]> </entry> <entry> <entry>670</entry> <entry> <![CDATA[4]]> </entry> <entry>666</entry> </entry> </entry> <entry> <entry>2</entry> <entry> <![CDATA[email2]]> </entry> <entry xsi:nil="true"/> <entry> <![CDATA[2016-03-05 09:14:47]]> </entry> <entry> <entry>110</entry> <entry>0</entry> <entry>110</entry> </entry> </entry> </entry> </result> |
Errori
Esempio di messaggio di errore :
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> |
Codice di controllo
Rispondi a | ||
---|---|---|
1 | La chiave API è richiesta | |
10 | Chiave API errata | |
200 | È andato tutto bene! |