有道是一個(gè)好公司,提供了好幾個(gè)非常好的免費(fèi)API,這里介紹:IP地址查詢、手機(jī)號碼歸屬地查詢、身份證查詢、郵編、區(qū)號、城市名查詢。
這幾個(gè)接口都是以URL GET方式提交參數(shù),以XML的形式返回查詢結(jié)果
查詢IP地址:
http://www.youdao.com/smartresult-xml/search.s?type=ip&q=IP地址
舉例:http://www.youdao.com/smartresult-xml/search.s?type=ip&q=123.233.157.9
返回:
<?xml version="1.0" encoding="gbk"?>
<smartresult>
<product type="ip">
<ip>123.233.157.9</ip>
<location>山東省濟(jì)南市 網(wǎng)通</location>
</product>
</smartresult>
查詢手機(jī)號碼歸屬地:
http://www.yodao.com/smartresult-xml/search.s?type=mobile&q=手機(jī)號
舉例:http://www.yodao.com/smartresult-xml/search.s?type=mobile&q=13892101111
返回:
<?xml version="1.0" encoding="gbk"?>
<smartresult>
<product type="mobile">
<phonenum>13892101111</phonenum>
<location>陜西 延安</location>
</product>
</smartresult>
查詢身份證信息:
http://www.yodao.com/smartresult-xml/search.s?type=id&q=身份證號碼
舉例:http://www.youdao.com/smartresult-xml/search.s?type=id&q=370782196402121133
返回:
<?xml version="1.0" encoding="gbk"?>
<smartresult>
<product type="identitycard">
<code>370782196402121133</code>
<location>山東省濰坊市諸城市</location>
<birthday>19640212</birthday>
<gender>m</gender>
</product>
</smartresult>
郵編、區(qū)號、城市名查詢城市信息:
http://www.yodao.com/smartresult-xml/search.s?type=zip&q=郵編或區(qū)號或城市名
舉例:http://www.youdao.com/smartresult-xml/search.s?type=zip&q=武漢
注:此時(shí)從輸入框獲取城市名需要:java.net.URLEncoder.encode(cityName,"UTF-8");當(dāng)為漢字的時(shí)候不處理直接訪問會得不到數(shù)據(jù)。
返回:
<?xml version="1.0" encoding="gbk"?>
<smartresult>
<product type="zipcode">
<province>湖北省</province>
<city>武漢市</city>
<location>湖北省 武漢市</location>
<phone>027</phone>
<zipcode>430000</zipcode>
</product>
</smartresult>
舉例:http://www.youdao.com/smartresult-xml/search.s?type=zip&q=021
返回:
<?xml version="1.0" encoding="gbk"?>
<smartresult>
<product type="zipcode">
<province></province>
<city>上海市</city>
<location>上海市</location>
<phone>021</phone>
<zipcode>200000</zipcode>
</product>
</smartresult>