具體代碼以下:php
<?phpjson
//根據手機號獲取運營商信息(淘寶API)
/*返回數據信息
Array
(
[mts] => 1316184
[province] => 北京
[catName] => 中國聯通
[telString] => 1316184xxxx
[areaVid] => 29400
[ispVid] => 137815084
[carrier] => 北京聯通
)
*/
function getOperatorByMoblieInTB($moblie=''){
if(empty($moblie)){
return 'moblie is empty!';
}
$url = 'https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=';
$api_url = $url.$moblie;
$s = file_get_contents($api_url);
preg_match_all("/(\w+):'([^']+)/", $s, $m);
$a = array_combine($m[1], $m[2]);
return $a;
}api
//根據手機號獲取運營商信息(360API)
/*返回數據信息
Array
(
[code] => 0
[data] => Array
(
[province] => 北京
[city] => 北京
[sp] => 聯通
)url
)
*/
function getOperatorByMoblieIn360($moblie=''){
if(empty($moblie)){
return 'moblie is empty!';
}
$url = 'http://cx.shouji.360.cn/phonearea.php?number=';
$api_url = $url.$moblie;
$res = file_get_contents($api_url);
$res = json_decode($res,1);
return $res;
}code