Vérification de format
- Home
- Vérification de format
Check the format of a number
This feature allows to check the size of a mobile phone number. It is free.
URLs
POST https://api.smspartner.fr/v1/lookup
Settings
Each API request supports the following parameters :
apiKey | API key from your account. You get it in your SMS Partner account |
---|---|
phoneNumbers | Mobile numbers to check. They must be in international format (+ 336xxxxxxxx). To send multiple checks the numbers must be separated by commas 500 numbers can be checked by request. |
Optional settings | |
_format | Response format. You can choose between JSON or XML . By default, the response format is JSON . |
/div>
Request
Sample query :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php // Prepare data for POST request $fields = array( 'apiKey'=> 'YOUR API KEY', 'phoneNumbers'=> '+336xxxxxxxx' ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/lookup'); 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 |
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 & "lookup" #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}""}}", apiKey, "+33XXXXXXXXX") 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 |
# 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) ]) url = URL + "/lookup" 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"}' https://api.smspartner.fr/v1/lookup |
Replies
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
{ "success": true, "code": 200, "lookup": [ { "request": "336XXXXXXXX", "success": true, "countryCode": "France", "prefixCode": 33, "phoneNumber": "+336XXXXXXXX", "type": "Mobile", "network": "", "format": { "e164": "+336XXXXXXXX", "international": "+33 6 XX XX XX XX", "national": "06 XX XX XX XX", "rfc3966": "tel:+33-6-XX-XX-XX-XX" } } ] } |
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 |
<?xml version="1.0" encoding="UTF-8"?> <result> <entry>true</entry> <entry>200</entry> <entry> <entry> <entry> <![CDATA[336XXXXXXXX]]> </entry> <entry>true</entry> <entry> <![CDATA[France]]> </entry> <entry>33</entry> <entry> <![CDATA[+336XXXXXXXX]]> </entry> <entry> <![CDATA[Mobile]]> </entry> <entry> <![CDATA[]]> </entry> <entry> <entry> <![CDATA[+336XXXXXXXX]]> </entry> <entry> <![CDATA[+33 6 XX XX XX XX]]> </entry> <entry> <![CDATA[06 XX XX XX XX]]> </entry> <entry> <![CDATA[tel:+33-6-XX-XX-XX-XX]]> </entry> </entry> </entry> </entry> </result> |
Errors
Error message Example :
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> |
Control code
Reply | ||
---|---|---|
1 | The API Key is required | |
2 | The phone number is required | |
3 | The numbers must be separated by commas | |
10 | Invalid API key | |
200 | Everything went well ! |