Invia una verifica
- Home
- Invia una verifica
Verifica della validità di un numero
Questa funzione verifica l’effettiva esistenza di un numero di cellulare.
Limite: 360 richieste al minuto.
Se si superano questi limiti, si riceve una risposta HTTP 429.
Se si superano questi limiti, si riceve una risposta HTTP 429.
URL
POST https://api.smspartner.fr/v1/hlr/notify
Impostazioni
Ogni richiesta PLC supporta i seguenti parametri :
apiKey | API key per il tuo account. Si ottiene nel vostro account Partner SMS |
---|---|
phoneNumbers | Numeri di cellulare da controllare. Devono essere in formato internazionale (+336xxxxxxxxxxxxxxxxxxxx). Quando si inviano più controlli, i numeri devono essere separati da virgole. 500 numeri possono essere verificati per ogni richiesta. |
Parametri opzionali | |
notifyUrl | Consente di recuperare il risultato della query HLR ad un URL di vostra scelta. Il risultato viene inviato in POST .
|
_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 18 19 20 21 22 |
<?php // Prepare data for POST request $fields = array( 'apiKey'=> 'YOUR API KEY', 'phoneNumbers'=> '+336xxxxxxxx', 'notifyUrl'=>'http://...' ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/hlr/notify'); 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 |
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 & "hlr/notify" #note : utiliser une librairie JSON en production, par exemple : #https//www.nuget.org/packages/Newtonsoft.Json/ Dim parameters As String = String.Format( "{{""apiKey"":""{0}"",""phoneNumbers"":""{1}"",""notifyUrl"":""{2}""}}", apiKey, "+33XXXXXXXXX", "http://...") 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 add_stop(self,phone_numbers): data = OrderedDict([ ("apiKey", API_KEY), ("phoneNumbers", phone_numbers, "notifyUrl", notify_url) ]) url = URL + "/hlr/notify" 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(r_json) status = False return status |
1 |
curl -H "Content-Type: application/json" -X POST -d '{"apiKey":"xxxxx","phoneNumbers":"xxxx","notifyUrl":"http://..."}' https://api.smspartner.fr/v1/hlr/notify |
Risposte
1 2 3 4 5 6 7 8 |
{ "success": true, "code": 200, "campaign_id": "HLR000000", "number": 1, "cost": 0.005, "currency": "EUR" } |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0" encoding="UTF-8"?> <result> <entry>true</entry> <entry>200</entry> <entry> <![CDATA[HLR0000000]]> </entry> <entry>1</entry> <entry>0.005</entry> <entry> <![CDATA[EUR]]> </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 | |
2 | Il numero di telefono è obbligatorio | |
3 | I numeri devono essere separati da una virgola. | |
10 | Chiave API errata | |
200 | È andato tutto bene! |
Esempio di notifica di una richiesta HLR HLR
1 2 3 4 5 6 7 8 9 10 |
Array( 'phone' => '+3300000000', 'messageId'=>'1234-12344-1234-1234', 'mccMnc' => '20815', 'ported'=> 1, 'errorGrpId'=> 0, 'errorName'=> 'NO_ERROR ', 'errorDesc'=>'No Error' , 'date'=>'2018-03-05T10:34:52.355+0000' ) |
Codici di errore HLR
errorGrpId | errorName | |
---|---|---|
0 | NO_ERROR Nessun errore. |
|
1 | EC_UNKNOWN_SUBSCRIBER Il numero non esiste o non è stato assegnato ad alcun abbonato attivo nel database utenti del gestore. |
|
5 | EC_UNIDENTIFIED_SUBSCRIBER Sottoscrittore non identificato. |
|
6 | EC_ABSENT_SUBSCRIBER_SM Poiché non c’è stata risposta, l’abbonato è stato rilevato come non disponibile. Ciò è spesso dovuto al fatto che il portatile è spento o in una zona con segnale basso. |
|
7 | EC_UNKNOWN_EQUIPMENT Il dispositivo mobile non è stato riconosciuto dall’EIR (Equipment Identity Register) quando ha controllato il dispositivo rispetto al protocollo MAP sull’infrastruttura dell’operatore. |
|
8 | EC_ROAMING_NOT_ALLOWED L’abbonato è attualmente in roaming in un altro paese o utilizza l’infrastruttura di un altro operatore – la fornitura di roaming non è garantita a causa della mancanza di accordi di roaming tra molti operatori diversi. |
|
9 | EC_ILLEGAL_SUBSCRIBER Abbonato illegale. |
|
12 | EC_ILLEGAL_EQUIPMENT Attrezzature illegali. |
|
13 | EC_CALL_BARRED L’abbonato è impostato sul servizio NPD (Do Not Disturb) e non riceve alcun traffico di servizio verso il suo numero. |
|
27 | EC_ABSENT_SUBSCRIBER L’abbonato è offline. Ciò è spesso dovuto al fatto che il portatile è spento. EC_UNKNOWN_ERROR Errore sconosciuto.. |
|
255 | EC_UNKNOWN_ERROR Erreur inconnue. |