骚扰电话识别接口api,php实现,360数据

 【做骚扰电话拦截,如果需要做联网识别可以用我这个接口】
http://1.harassphone.applinzi.com/phone.php?phone=15677246297
【json返回数据示例:type为空则不是骚扰电话】
{"phone":"15677246297","where":"广西柳州","cmcc":"联通","type":"响一声电话!请谨慎回拨!"}
{"phone":"4000024005","where":"","cmcc":"","type":"骚扰电话"}
{"phone":"17092908843","where":"陕西西安","cmcc":"蜗牛移动","type":"骚扰电话"}
【需要注意的是:服务器流量要钱的,不要恶意刷并发,没钱续费】
我也不知道我几时会把这个接口停掉,所以给出php源码,需要的可以部署在自己的服务器上使用
<?php
class Result{
 var  $phone;
 var  $where;
 var  $cmcc;
 var  $type;
}
function get($url = '') {
 	$ch = curl_init();
 	curl_setopt($ch, CURLOPT_URL, $url);
 	curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true);
 	$output = curl_exec($ch);
	curl_close($ch);
 	return $output; 
 }
 function get_tag( $attr, $value, $xml, $tag=null ) {  
  if( is_null($tag) )  
    $tag = '\w+';  
  else  
    $tag = preg_quote($tag);  
  
  $attr = preg_quote($attr);  
  $value = preg_quote($value);  
  
  $tag_regex = "/<(".$tag.")[^>]*$attr\s*=\s*".  
                "(['\"])$value\\2[^>]*>(.*?)<\/\\1>/";
  
  preg_match_all($tag_regex,  
                 $xml,  
                 $matches,  
                 PREG_PATTERN_ORDER);  
  
  return $matches[3];  
}  
 header('Content-type:text/json'); 
 $phone=$_GET['phone'];
 $type_t="";
 $txt=get('https://www.so.com/s?q='.$phone);
 $info=get_tag("class","mohe-mobileInfoContent",$txt,"td");
 $where=get_tag("class","gclearfix mh-detail",$info[0],"div");
 if(count($where)==0){//不是骚扰电话
     $where=get_tag("class","mh-detail",$info[0],"p");
 }
 $info_txt= strip_tags ($where[0]);
 $info_array=explode("  ",$info_txt);
 $phone_t=$info_array[0];
 $where_t=$info_array[1];
 $cmcc_t=$info_array[2];
 $type=get_tag("class","mohe-ph-mark",$info[0],"span");
 if(count($type)!=0){
     $type_t=$type[0];
 }

 $result=new Result();
  $result->phone=$phone_t;
  $result->where=$where_t;
  $result->cmcc=$cmcc_t;
  $result->type=$type_t;
 
 $json=json_encode($result,JSON_UNESCAPED_UNICODE);
 echo $json;
 
 
?>
php5.4以上

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值