import com.baidubce.http.ApiExplorerClient; import com.baidubce.http.AppSigner; import com.baidubce.http.HttpMethodName; import com.baidubce.model.ApiExplorerRequest; import com.baidubce.model.ApiExplorerResponse; // 手机号二要素验证 Java示例代码 public class RequestDemo { public static void main(String[] args) { String path = "http://teltwo.api.bdymkt.com/lundear/telTwo"; ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.GET, path); request.setCredentials("您的 access key", "您的 secret key"); request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8"); request.addQueryParameter("mobile", ""); request.addQueryParameter("name", ""); ApiExplorerClient client = new ApiExplorerClient(new AppSigner()); try { ApiExplorerResponse response = client.sendRequest(request); // 返回结果格式为Json字符串 System.out.println(response.getResult()); } catch (Exception e) { e.printStackTrace(); } } }
点击复制代码
{
"code": 0,
"desc": "一致",
"data": {
"isp": "移动", //运营商名称【如果已携号转网,返回的是当前所在运营商的名称】
"province": "北京", //手机号归属省份
"city": "北京", //手机号归属城市
"postcode": "100000", //邮政编码
"areacode": "010" //区号
}
}
{
"code": 5,
"desc": "身份证号格式错误"
}
应答码code说明:
0:一致
1:不一致
2:查无记录
3:不支持的号段
4:姓名格式错误
95:该号码请求过于频繁
96:交易失败,请稍后重试【运营商异常或维护导致的原因】
字段解释:
postcode:邮政编码
areacode:区号
isp:运营商名称【如果已携号转网,返回的是当前所在运营商的名称】
city:手机号归属地
目前已有多家独角兽企业、银行、保险公司使用该产品。