function getBalance($mobile) {
$API_KEY = '5645226545SD6F';// 控制台密钥
$API_URL = 'https://www.acbapi.com/api/huafei';// 接口地址
$sk = '12345674898897489789498';// 32位自定义
// 判断号码所属运营商
$yd = array("134", "135", "136", "137", "138", "139", "144", "147", "148", "150", "151", "152", "157", "158", "159", "165", "170", "172", "178", "182", "183", "184", "187", "188", "195", "198");
$lt = array("130", "131", "132", "155", "156", "166", "175", "176", "185", "186");
$dx = array("133", "149", "153", "173", "177", "180", "181", "189", "190", "191", "193", "199");
$isp = "";
$yys = "";
$prefix = substr($mobile, 0, 3);
if (in_array($prefix, $yd)) {
$isp = 'yd';
$yys = '中国移动';
} else if (in_array($prefix, $lt)) {
$isp = 'lt';
$yys = '中国联通';
} else if (in_array($prefix, $dx)) {
$isp = 'dx';
$yys = '中国电信';
} else {
// handle error here if prefix does not match any known carrier
}
$get_post_data = array(
'key' => $API_KEY,
'mobile' => $mobile,
'isp' => $isp,
'order' => time(),
);
$resdata = api::send($API_URL, $get_post_data, 'POST', false, $sk);
$response = json_decode($resdata, true);
$response['yys'] = $yys;
return $response;
}
上篇内容漏了isp的调用方法了,直接本地识别是哪个运营商的,但是也有弊端,运营商更新了,号段不在这里面就查询失败了 。
┭┮﹏┭┮