|
@@ -194,14 +194,14 @@ function card_type($cardno,&$regin_no)
|
|
|
}
|
|
|
elseif(preg_match('/^1\d{10}$/',$cardno,$matches))
|
|
|
{
|
|
|
- $region_no = -1;
|
|
|
- $checker = function ($phone) use(&$region_no)
|
|
|
+ $checker = function ($phone,&$region)
|
|
|
{
|
|
|
if (empty($phone)) return false; //手机号不能为空
|
|
|
$url = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel={$phone}";
|
|
|
$resp = http_request($url); //获取API返回 的数据
|
|
|
- $resp = mb_convert_encoding($resp, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5'); //解决中文乱码
|
|
|
+ if(empty($resp)) return false;
|
|
|
|
|
|
+ $resp = mb_convert_encoding($resp, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5'); //解决中文乱码
|
|
|
$datas = explode('=', $resp);
|
|
|
if(count($datas) == 2)
|
|
|
{
|
|
@@ -210,7 +210,7 @@ function card_type($cardno,&$regin_no)
|
|
|
$res = array_combine($m[1], $m[2]);
|
|
|
|
|
|
$province = formatProvince($res['province']);
|
|
|
- $region_no = array_search($province,ProvinceList);
|
|
|
+ $region = array_search($province,ProvinceList);
|
|
|
return $res;
|
|
|
}
|
|
|
}
|
|
@@ -218,7 +218,7 @@ function card_type($cardno,&$regin_no)
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
- $ret = $checker($cardno);
|
|
|
+ $ret = $checker($cardno,$region);
|
|
|
if (empty($ret))
|
|
|
{
|
|
|
Log::record("淘宝接口没法使用了,用传统办法识别卡类型",Log::DEBUG);
|
|
@@ -233,12 +233,15 @@ function card_type($cardno,&$regin_no)
|
|
|
}
|
|
|
}
|
|
|
elseif($ret['catName'] == '中国联通') {
|
|
|
+ $regin_no = $region;
|
|
|
return ChinaUnicomCard;
|
|
|
}
|
|
|
elseif($ret['catName'] == '中国电信') {
|
|
|
+ $regin_no = $region;
|
|
|
return ChinaTelecomCard;
|
|
|
}
|
|
|
elseif($ret['catName'] == '中国移动') {
|
|
|
+ $regin_no = $region;
|
|
|
return ChinaMobileCard;
|
|
|
}
|
|
|
else {
|