手機號碼歸屬地查詢API

推薦幾個可用的免費接口

淘寶接口

https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=13822228888

360接口

http://cx.shouji.360.cn/phonearea.php?number=13366662222

阿里雲上面還有一些收費接口

0.01元/1000次

免費10000次

附上我對接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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章