手机号码归属地查询API
推荐几个可用的免费接口
淘宝接口
https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13822228888
360接口
http://cx.shouji.360.cn/phonearea.php?number=13366662222
阿里云上面还有一些收费接口
附上我对接360接口的代码
Scala版本的代码
val phone = "13622228888"
val httpClient = HttpClients.createDefault
val httpGet = new HttpGet(s"http://cx.shouji.360.cn/phonearea.php?number=${phone}")
val httpResponse = httpClient.execute(httpGet)
val response = EntityUtils.toString(httpResponse.getEntity, "UTF-8")
val data = JSON.parseObject(response).get("data").toString
val city = JSON.parseObject(data).get("city").toString
println(city)
httpGet.releaseConnection()
httpClient.close()
Maven依赖
<dependency>
<groupId>org.wso2.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1.wso2v1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>