1. 电话归属
查询电话号码的归属地
字段名 |
字段位置 |
字段类型 |
字段说明 |
举例 |
必选 |
apiv |
head |
string |
API版本,默认是1.0.0 |
1.0.0 |
可选 |
Authorization |
head |
string |
客户端保存的鉴权token |
Authorization字符串 |
必选 |
phone |
path |
string |
查询的11位手机号码或手机号码的前7位 |
必选 |
返回数据
{
"error": 0,
"reason": 'Success',
"result":{
"phone_number": '手机号码',
"city":"手机号归属地",
"operator": '运营商'
}
}
成功返回
字段名 |
字段类型 |
字段说明 |
phone |
string |
查询的11位手机号码或手机号码的前7位 |
city |
string |
手机号的归属地 |
operator |
string |
运营商 |
失败返回
{
"error": 1,
"reason": "失败原因",
"result": {"失败的参考数据"},
}
1.1. 错误码
错误码来自于error字段
错误码 |
错误码名 |
说明 |
可能原因 |
2000 |
服务成功完成 |
成功 |
服务成功完成。 |
2011 |
无效的手机号 |
成功 |
以下三种情况会返回“号码格式错误”:输入的手机号不是整数/手机号长度不是11位或前7位/手机号前3位为不支持的网络识别号。在查询归属地时,服务器端会截取手机号码的前7位,其中前3位为网络识别号(比如138为中国移动号段,181位中国电信号段),后4位为地区编码(比如1050为北京). |
2012 |
获取信息失败 |
成功 |
在查询归属地时,输入的手机号的前7位不属于规定的手机号前缀 |
2013 |
获取信息例外 |
成功 |
在查询归属地时,因各种原因和例外,获取信息失败 |
1.2. Browser SDK调用示例代码
const hannm = require('../lib/hannm')
async function test_getTeloc() {
const ham = await hannm({
APP_KEY: "aHEVYhE1",
APP_SECRET: "f34b127abc7cca1862dac91db6256190",
})
let api_name = "电话归属";
let res = await ham.getTeloc("15810419011")
console.log(res);
console.log(JSON.stringify(res));
if(res.error == 0){
console.log(api_name+"成功 ");
}else{
console.log(api_name+"失败 "+res.reason);
}
}