现在的位置: 首页 > 综合 > 正文

通过GeoIP获取ip所属地 (国家,城市,时区,邮编,经纬度等)

2014年01月11日 ⁄ 综合 ⁄ 共 1427字 ⁄ 字号 评论关闭

或者 使用某网站的API

 

API 1.

 

1. 返回文字

 

Html代码  收藏代码
  1. http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true  

 

2. 返回图片

 

Html代码  收藏代码
  1. <IMG SRC="http://api.hostip.info/flag.php?ip=12.215.42.19" ALT="IP Address Lookup">  

 

 

API 2. (需要申请api key ,免费的,类似google)

 

城市:

 

Html代码  收藏代码
  1. http://api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&ip=74.125.45.100  

 

国家(更快) :

 

Html代码  收藏代码
  1. http://api.ipinfodb.com/v3/ip-country/?key=<your_api_key>&ip=74.125.45.100  

 

 

Parameter Required Default Value

key Yes <empty> API key provided with your free account.
ip No Client IP IP address
format No raw raw, xml, json
callback No <empty> Required when using json callback.

Please use the appropriate API for your needs. You can help us keep the load low on our servers by making sure that :

  • If you only need the country name, avoid using the city precision API.
  • If you track your visitors, avoid querying our API for all your page views (you can store the geolocation in a cookie, see below for an example)

API Precision Timezone Domains lookups

ip-city City Yes Yes
ip-country Country No Yes

Please use the appropriate API for your needs. You can help us keep the load low on our servers by making sure that :

  • If you only need the country name, avoid using the city precision API.
  • If you track your visitors, avoid querying our API for all your page views (you can store the geolocation in a cookie, see below for an example)
  • key: c9dcc88453e33a9e63ebad8d65f91583e87abd8185dd95f09fbeef6c62264f7d

     

    其他参考

    http://pecl.php.net/package/geoip

    http://www.geoiptool.com/

    http://www.hostip.info/use.html

    http://phpweby.com/software/ip2country

    http://www.ipinfodb.com/index.php

抱歉!评论已关闭.