What services exist that geo-locates a person base

2020-06-03 09:14发布

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?

4条回答
ゆ 、 Hurt°
2楼-- · 2020-06-03 09:59

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

A buddy of mine is using is with success.

查看更多
女痞
3楼-- · 2020-06-03 10:03

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楼-- · 2020-06-03 10:04

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

查看更多
淡お忘
5楼-- · 2020-06-03 10:12

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);
查看更多
登录 后发表回答