接口地址:http://op.juhe.cn/onebox/phone/query |
---|
返回格式:json/xml |
请求方式:get/post |
请求示例:http://op.juhe.cn/onebox/phone/query?tel=051262519280&key=您申请的KEY |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
key | string | 必填 | 应用APPKEY,申请数据系统分配 扫码关注公众号 |
tel | string | 必填 | 要查询的号码,如:051262519280 |
dtype | string | 选填 | 返回数据的格式,xml或json,默认json |
名称 | 类型 | 说明 |
---|---|---|
error_code | int | 返回码 |
reason | string | 返回说明 |
result | string | 返回结果集 |
{
"reason": "查询成功",
"result": {
"iszhapian": 1,
/*是否诈骗、营销、广告电话*/
"province": "",
/*号码所属省份*/
"city": "上海",
/*号码所属城市*/
"sp": "",
/*号码所属运营商*/
"phone": "02151860253",
/*查询号码*/
"rpt_type": "房产中介",
/*号码性质*/
"rpt_comment": "房产中介",
/*号码性质描述*/
"rpt_cnt": 24,
/*标记人数*/
"hy": { /*号码详细,可能部分号码为NULL*/
"city": "上海",
"lng": "0",
"lat": "0",
"name": "上海xxxxxx有限公司",
"addr": "",
"tel": "021-51860253"
},
"hyname": "该号码所属公司名称",
"countDesc": "此号码近期被360手机卫士用户标记为房产中介电话!"
},
"error_code": 0 /*返回码:0表示查询成功*/
}
错误码 | 说明 |
---|---|
207201 | 查询的号码不能为空 |
207202 | 查询不到相关信息 |
207203 | 网络错误,请重试 |
10001 | 错误的请求KEY |
10002 | 该KEY无请求权限 |
10003 | KEY过期 |
10004 | 错误的OPENID |
10005 | 应用未审核超时,请提交认证 |
10007 | 未知的请求源 |
10008 | 被禁止的IP |
10009 | 被禁止的KEY |
10011 | 当前IP请求超过限制 |
10012 | 请求超过次数限制 |
10013 | 测试KEY超过请求限制 |
10014 | 系统内部异常(调用充值类业务时,请务必联系客服或通过订单查询接口检测订单,避免造成损失) |
10020 | 接口维护 |
10021 | 接口停用 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2019/3/15 17:50
*/
//----------------------------------
// 聚合 手机固话来电显示 调用类
//----------------------------------
class freeApi{
private $apiKey = false; //聚合appkey
private $apiUrl = 'http://op.juhe.cn/onebox/phone/query';
public function __construct($apikey){
$this->apiKey = $apikey;
}
/**
* 将JSON内容转为数据,并返回
* @param string $content [内容]
* @return array
*/
public function returnArray($content){
return json_decode($content,true);
}
/**
* 获取 手机固话来电显示 结果
* @return array
*/
public function getResult(){
$params = [
"key" => $this->apiKey,//应用APPKEY(应用详细页查询)
"tel" => "",//要查询的号码,如:02151860253、051263291880
"dtype" => "",//返回数据的格式,xml或json,默认json
];
$params = http_build_query($params);
return $this->returnArray($this->freeApiCurl($this->apiUrl,$params,1));
}
/**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int $ipost [是否采用POST形式]
* @return string
*/
public function freeApiCurl($url,$params=false,$ispost=0){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
if( $ispost )
{
curl_setopt( $ch , CURLOPT_POST , true );
curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
curl_setopt( $ch , CURLOPT_URL , $url );
}
else
{
if($params){
curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
}else{
curl_setopt( $ch , CURLOPT_URL , $url);
}
}
$response = curl_exec( $ch );
if ($response === FALSE) {
return false;
}
curl_close( $ch );
return $response;
}
}