Implement application to detect country by phone number.
<?php
include_once("core/config.php");
include_once("core/PhoneVerification.php");
include_once("core/JsonResponse.php");
$phoneVerification = new PhoneVerification();
$codes = $phoneVerification->loadCountriesCodes();
if (count($codes) == 0)
{
$phoneVerification->setResult("fail", "Countries list is empty.");
}
else
{
$code = $phoneVerification->extractCountryCode($_GET['number']);
//$code = $p->extractCountryCode('37126856232');
if (array_key_exists($code, $codes)) {
$phoneVerification->setResult("success", "Country: ".$codes[$code]);
}
else
{
$phoneVerification->setResult("fail", "Country not found.");
}
}
$result = new JsonResponse();
$result->status = $phoneVerification->status;
$result->message = $phoneVerification->message;
$json = json_encode($result);
echo $json;