Phone Validation

Last updated: September 14th, 2018

OVERVIEW

This API validates phone numbers (only Republic of Moldova) in several valid formats and returns the mobile carrier name.

REQUEST & RESPONSE

The API uses GET method to send request. Below you can find sample synax.

Request Method:

GET https://apineo.app/phone-validation/?phone_number=037379528887

Response "VALID"

Below you can find a "valid" response sample.

Sample Request:

GET https://apineo.app/phone-validation/?phone_number=037379528887

Result:
{
    "success": true,
    "result": "valid",
    "number": "037379528887",
    "carrier": "Moldcell",
    "country_code": "MD",
    "execution_time_spent": 0.00012493133544921875
}

Response "INVALID"

Below you can find an "invalid" response sample.

Sample Bad Request:

GET https://apineo.app/phone-validation/?phone_number=037279528887

Result:
{
    "success": true,
    "result": "invalid",
    "number": "037279528887",
    "info": "Only valid Moldova (Republic of) phone numbers are allowed.",
    "valid_format_examples": [
        "79515556",
        "079515556",
        "+37379515556",
        "+373079515556",
        "0373079515556",
        "037379515556",
        "022665599",
        "023528659",
        "+37323528659",
        "037323528659"
    ],
    "execution_time_spent": 0.0002689361572265625
}

Response "ERROR"

Below you can find an "error" response.

Sample Bad Request:

GET https://apineo.app/phone-validation/?phone

Result:
{
    "success": false,
    "error": "Error. You must provide a phone number.",
    "valid_syntax_example": "https://apineo.app/phone-validation/?phone_number=+37379528887",
    "info": "Only valid Moldova (Republic of) phone numbers are allowed.",
    "valid_format_examples": [
        "79515556",
        "079515556",
        "+37379515556",
        "+373079515556",
        "0373079515556",
        "037379515556",
        "022665599",
        "023528659",
        "+37323528659",
        "037323528659"
    ],
    "execution_time_spent": 7.0810317993164062e-5
}

SAMPLE CODES

Below you can find a usage sample php code using cURL.

PHP Code Example
<?php 
//Validation function using cURL
function validate_phone($phone_number){
	$ch = curl_init("https://apineo.app/phone-validation/?phone_number=".$phone_number."");  
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$json = curl_exec($ch);
	curl_close($ch);
	$validationResult = json_decode($json, true);
	if($validationResult["result"]=="valid"){
		return true;
	}else{
		return false;
	}
	
} 

//USAGE
if(validate_phone("037379528887")){
	//do success code ...
}else{
	//do error code ...
}
?>