HLR HTTP z
Uzyskaj status numeru telefonu stacjonarnego lub komórkowego za pomocą Java
Java : DOKUMENTACJA API
- Utwórz grupę za pomocą Java
- Uzyskaj listę pól grupy za pomocą Java
- Dodaj pole do grupy za pomocą Java
- Usuń pole z grupy za pomocą Java
- Usuń kontakt z grupy
- Pomoc krajowi w grupie z Java
- Uzyskaj listę kontaktów grupy za pomocą Java
- Dodaj kontakt do grupy za pomocą Java
- Zmodyfikuj kontakt grupy za pomocą Java
- Usuń kontakt grupy za pomocą Java
HLR HTTP z
String afilnet_class="hlr";
String afilnet_method="checkphonenumbers";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_numbers="100000000,100000001,100000002";
// Create an URL request
String sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&numbers="+afilnet_numbers;
URL url = new URL(sUrl);
StringBuilder builder = new StringBuilder();
BufferedReader theJSONline = new BufferedReader(new InputStreamReader(url.openStream()));
builder.append(theJSONline.readLine());
String content = builder.toString();
String afilnet_class="hlr";
String afilnet_method="checkphonenumbers";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_numbers="100000000,100000001,100000002";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&numbers="+afilnet_numbers;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/http/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
String afilnet_class="hlr";
String afilnet_method="checkphonenumbers";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_numbers="100000000,100000001,100000002";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&numbers="+afilnet_numbers;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/basic/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
String encoded = Base64.getEncoder().encodeToString((afilnet_user+":"+afilnet_password).getBytes(StandardCharsets.UTF_8));
con.setRequestProperty("Authorization", "Basic "+encoded);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
Parametr | Opis | Obowiązkowe / opcjonalne |
---|---|---|
class=hlr | Klasa wymagana: klasa, do której kierowane jest żądanie | Obowiązkowe |
method=checkphonenumbers | Żądana metoda klasy: metoda klasy, do której kierowane jest żądanie | Obowiązkowe |
user | Użytkownik i adres e-mail Twojego konta Afilnet | Obowiązkowe |
password | Hasło do konta Afilnet | Obowiązkowe |
numbers | Lista numerów telefonów wraz z kodem kraju oddzielonych przecinkami (przecinki) | Obowiązkowe |
Kiedy będziesz składać wnioski, otrzymasz następujące pola:
- status
-
wynik (jeśli status = sukces), tutaj otrzymasz następujące wartości:
- credits
-
list
- number
- mccmnc
- imsi
- onname
- onprefix
- oncountry
- ported
- portedcountry
- portedname
- portedprefix
- error
- permanent_error
- error (if status = error), tutaj otrzymasz kod błędu
Możliwe kody błędów są wymienione poniżej
Kod | Opis |
---|---|
MISSING_USER | Użytkownik lub adres e-mail nie są uwzględnione |
MISSING_PASSWORD | Hasło nie jest wliczone |
MISSING_CLASS | Klasa nie jest wliczona |
MISSING_METHOD | Metoda nie jest uwzględniona |
MISSING_COMPULSORY_PARAM | Obowiązkowy parametr nie jest uwzględniony |
INCORRECT_USER_PASSWORD | Niepoprawny użytkownik lub hasło |
INCORRECT_CLASS | Niepoprawna klasa |
INCORRECT_METHOD | Niepoprawna metoda |
Parametry:
- class : hlr
- method : checkphonenumbers
- user : user
- password : password
- numbers : 100000000,100000001,100000002
Zapytanie:
https://www.afilnet.com/api/http/?class=hlr&method=checkphonenumbers&user=user&password=password&numbers=100000000,100000001,100000002