任何可靠的API可用于从IP地址确定用户的城市和国家/地区

Gub*_*ooo 18 php ip-geolocation

嘿伙计们

我想检查是否有人知道我们可以用来从他的IP地址确定用户的城市和国家的可靠API.

我在Google上的搜索引发了http://ipinfodb.com/ip_location_api.php

这看起来很完美,但我唯一关心的是这项服务的可靠性.谷歌有这样的东西吗?如果您知道任何其他免费或付费的API,以帮助确定用户的IP位置 - 请告诉我

谢谢

Kje*_*dal 12

MaxMind有他们的ip2country和ip2city数据库的精简版:http: //www.maxmind.com/app/geolitecity

http://www.maxmind.com/app/geolitecountry

如果你不介意自己托管数据库,它是免费的.付费服务更准确.

它们还提供用于查询的Web服务,但它不是免费的:http: //www.maxmind.com/app/web_services#country


Cha*_*kka 11

考虑使用geoplugin,它提供来自单行PHP代码的大部分信息,但需要连接到geoplugin.com服务器以获取每个请求(并且它是免费的).

例子 :

Json:http://www.geoplugin.net/json.gp? ip = 74.125.236.174

{
geoplugin_request: "74.125.236.174",
geoplugin_status: 200,
geoplugin_city: "Mountain View",
geoplugin_region: "CA",
geoplugin_areaCode: "650",
geoplugin_dmaCode: "807",
geoplugin_countryCode: "US",
geoplugin_countryName: "United States",
geoplugin_continentCode: "NA",
geoplugin_latitude: "37.419201",
geoplugin_longitude: "-122.057404",
geoplugin_regionCode: "CA",
geoplugin_regionName: "California",
geoplugin_currencyCode: "USD",
geoplugin_currencySymbol: "$",
geoplugin_currencySymbol_UTF8: "$",
geoplugin_currencyConverter: 1
}
Run Code Online (Sandbox Code Playgroud)

Xml:http://www.geoplugin.net/xml.gp? ip = 74.125.236.174

<geoPlugin>
<script/>
<geoplugin_request>74.125.236.174</geoplugin_request>
<geoplugin_status>200</geoplugin_status>
<geoplugin_city>Mountain View</geoplugin_city>
<geoplugin_region>CA</geoplugin_region>
<geoplugin_areaCode>650</geoplugin_areaCode>
<geoplugin_dmaCode>807</geoplugin_dmaCode>
<geoplugin_countryCode>US</geoplugin_countryCode>
<geoplugin_countryName>United States</geoplugin_countryName>
<geoplugin_continentCode>NA</geoplugin_continentCode>
<geoplugin_latitude>37.419201</geoplugin_latitude>
<geoplugin_longitude>-122.057404</geoplugin_longitude>
<geoplugin_regionCode>CA</geoplugin_regionCode>
<geoplugin_regionName>California</geoplugin_regionName>
<geoplugin_currencyCode>USD</geoplugin_currencyCode>
<geoplugin_currencySymbol>&#36;</geoplugin_currencySymbol>
<geoplugin_currencySymbol_UTF8>$</geoplugin_currencySymbol_UTF8>
<geoplugin_currencyConverter>1</geoplugin_currencyConverter>
</geoPlugin>
Run Code Online (Sandbox Code Playgroud)

其他选择


cod*_*ict 7

我使用过http://www.hostip.info/,发现它真的很棒.

  • 刚刚检查了正在使用2年的IP.它甚至无法找到我的国家.不确定它对国际查询有好处...... (2认同)

SF.*_*SF. 5

每个IP地理位置都取决于ISP提交的记录.这将永远不会完全可靠,因为许多ISP提交其办公室的位置而不是其子网的物理位置,这些子网可能位于不同的城市甚至国家.