手机号码归属地查询api接口(实例)

拍拍接口

<?php
@header(‘Content-type: text/html;charset=UTF-8′);
function get_mobile_area($phone){
$url = “http://virtual.paipai.com/extinfo/GetMobileProductInfo?mobile=”.$phone.”&amount=10000″;
$dos = file_get_contents($url);
$province = substr($dos, 33, 4);
$cityname = substr($dos, 115, 4);
$isp = substr($dos, 48, 4);
return $str = conv2utf8($province).conv2utf8($cityname).conv2utf8($isp);
}

function conv2utf8($text){
return mb_convert_encoding($text,’UTF-8′,’ASCII,GB2312,GB18030,GBK,UTF-8’);
}
echo get_mobile_area($phone);
?>

[dm href=”http://www.ota.hk/“]链接地址[/dm][dl href=”http://www.ota.hk/“]下载链接[/dl][gt href=”http://www.ota.hk/“]开源地址[/gt]

财付通接口

<?php
@header(‘Content-type: text/html;charset=UTF-8’);
function get_mobile_area($phone){
$url = “https://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=”.$phone;
$str = file_get_contents($url);
$xml = simplexml_load_string($str);
$referdata = json_decode(json_encode($xml),true);
$auths = trim($referdata[‘province’]).trim($referdata[‘city’]).trim($referdata[‘supplier’]);
print_r($auths);
}

echo get_mobile_area($phone);
?>