查询手机归属地接口

0
(0)
@Test
    public void testGetProvince() {

        String phoneNumber = "18629020328";
        String url = "http://apis.baidu.com/apistore/mobilephoneservice/mobilephone?apikey=6e825bd531b8b1839fc1cda66b19edb9&tel="+phoneNumber;
        try {
            HttpResponse resp = HttpClientHelper.INSTANCE.get(url, null, new Header[]{new BasicHeader("apikey", "6e825bd531b8b1839fc1cda66b19edb9")});
            String s = EntityUtils.toString(resp.getEntity(), "UTF-8");

            System.out.println(s);

            JsonNode jsonNode = JsonObjectUtils.stringToJsonNode(s);
            if (jsonNode.get("retMsg").getTextValue().equals("success")) {
                System.out.println(jsonNode.get("retData").get("supplier").getTextValue());
                System.out.println(jsonNode.get("retData").get("province").getTextValue());
                System.out.println(jsonNode.get("retData").get("city").getTextValue());
                System.out.println(jsonNode.get("retData").get("suit").getTextValue());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

 

这篇文章有用吗?

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位评论此文章。

很抱歉,这篇文章对您没有用!

让我们改善这篇文章!

告诉我们我们如何改善这篇文章?

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据