public function telselect(){//手机号归属地查询接口,公共接口
//验证来源域名
// $urlcomplete=$this->geturlcomplete();
// echo 22;exit;
$url='http://www.baidu.com/s?wd='.$_REQUEST['tel'];
$str=httpsRequestlison($url,'');
$getinfo=explode('手机号码"'.$_REQUEST['tel'],$str);
$getinfo=substr($getinfo[1],72,80);
// var_dump($getinfo);exit;
if(!$getinfo){
$getinfo='';
}elseif(strpos($getinfo,'天津')){
$getinfo='天津市';
}elseif(strpos($getinfo,'北京')){
$getinfo='北京市';
}elseif(strpos($getinfo,'重庆')){
$getinfo='重庆市';
}elseif(strpos($getinfo,'上海')){
$getinfo='上海市';
}else{
$getinfo=substr_replace($getinfo,"省",strpos($getinfo,' '),strlen(' '));//只替换第一个字符
$getinfo=substr_replace($getinfo,"市",strpos($getinfo,' '),strlen(' '));//只替换第一个字符
$getinfo=str_replace(' ', '', $getinfo);
$getinfo=str_replace("\n", '', $getinfo);
$getinfo=str_replace(" ", '', $getinfo);
$getinfo=str_replace('中国移动', '', $getinfo);
$getinfo=str_replace('中国电信', '', $getinfo);
$getinfo=str_replace('中国联通', '', $getinfo);
}
$getinfo=str_replace('</span></div>', '', $getinfo);
// var_dump($getinfo);exit;
if(empty($getinfo)){
// echo 77;exit;
$url='https://shouji.supfree.net/fish.asp?cat='.$_REQUEST['tel'];
$str=httpsRequestlison($url,'');
$str=iconv("GB2312","UTF-8",$str);//GB2312转换为utf-8
preg_match('/<p><span class="bgreen">归属地:<(.*?)>(.*?)<\/p>/i', $str, $mach);
// var_dump($mach[2]);exit;
$getinfo=$mach[2];
}
if(empty($getinfo)){
echo '';exit;
}
//过滤自治区
if(strpos($getinfo,'新疆') !== false){
$sheng='新疆';
$shi=mb_substr($getinfo,mb_strpos($getinfo,"省")+1);
$shi=$shi ? $shi : mb_substr($getinfo,mb_strpos($getinfo,"区")+1);
}elseif(strpos($getinfo,'西藏') !== false){
$sheng='西藏';
$shi=mb_substr($getinfo,mb_strpos($getinfo,"省")+1);
$shi=$shi ? $shi : mb_substr($getinfo,mb_strpos($getinfo,"区")+1);
}elseif(strpos($getinfo,'宁夏') !== false){
$sheng='宁夏';
$shi=mb_substr($getinfo,mb_strpos($getinfo,"省")+1);
$shi=$shi ? $shi : mb_substr($getinfo,mb_strpos($getinfo,"区")+1);
}elseif(strpos($getinfo,'内蒙古') !== false){
$sheng='内蒙古';
$shi=mb_substr($getinfo,mb_strpos($getinfo,"省")+1);
$shi=$shi ? $shi : mb_substr($getinfo,mb_strpos($getinfo,"区")+1);
}
//过滤直辖市
if(strpos($getinfo,'北京') !== false){
$sheng='北京';
$shi='北京';
}elseif(strpos($getinfo,'天津') !== false){
$sheng='天津';
$shi='天津';
}elseif(strpos($getinfo,'上海') !== false){
$sheng='上海';
$shi='上海';
}elseif(strpos($getinfo,'重庆') !== false){
$sheng='重庆';
$shi='重庆';
}
//过滤普通市
if(strpos($getinfo,'省') !== false){
$sheng=substr($getinfo,0,strpos($getinfo,"省"));
$shi=mb_substr($getinfo,mb_strpos($getinfo,"省")+1);
$shi=$shi ? $shi : mb_substr($getinfo,mb_strpos($getinfo,"区")+1);
}
$arrs=array('sheng'=>$sheng,'shi'=>$shi);
$type=$_REQUEST['type'] ? 1 : '';
if($type){
echo $sheng.'省'.$shi;exit;
}
// dump($arrs);exit;
echo json_encode($arrs);
}