@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(); } }
了解 工作生活心情记忆 的更多信息
订阅后即可通过电子邮件收到最新文章。