What services exist that geo-locates a person based on IP? [closed]

假装没事ソ 提交于 2019-12-09 05:54:57

问题


What do people use to geo-locate a persons IP to determine the city they are in?

I've tried the built in functionality of Google API but its geo-location database seem spotty.

http://code.google.com/apis/ajax/documentation/#ClientLocation

Anyone use any other service for geo-locating with success?


回答1:


The most stable company I've seen that does it is MaxMind.

A buddy of mine is using is with success.




回答2:


There is a community-based Geotargeting service from hostip.info. They have a nice clean API for Geotargeted IP Address Lookup. They've got over 8.6 million entries in their database.

Example:

http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
  Country: UNITED STATES (US)
  City: Sugar Grove, IL
  Latitude: 41.7696
  Longitude: -88.4588

if you add just call:

http://api.hostip.info/?ip=12.215.42.19

You'll get an XML document back.

Source: Scott Hanselman - The Weekly Source Code 37 - Geolocation/Geotargeting (Reverse IP Address Lookup) in ASP.NET MVC made easy




回答3:


I've used IPInfoDB (which may use the same database as MaxMind) which has straightforward XML and JSON formats to their API, along with Google's ClientLocation. Neither is perfect and they often disagree. I haven't really found one to be better than the other.




回答4:


I'm using Codehelper.io Their PHP Class is nice, they can detect real IP for you, and get location , returned JSON with country, city, latidude, calling code, user's languages and more.

They also support Javascript. Check out example at their site.

<?php
// Required Libraries
require_once("ip.codehelper.io.php");
require_once("php_fast_cache.php");

// New Class
$_ip = new ip_codehelper();

// Detect Real IP Address & Location
$real_client_ip_address = $_ip->getRealIP();
$visitor_location       = $_ip->getLocation($real_client_ip_address);

// Output result
echo $visitor_location['Country']."";
echo "<pre>";
print_r($visitor_location);


来源:https://stackoverflow.com/questions/464142/what-services-exist-that-geo-locates-a-person-based-on-ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!