IP to location API
Component ID
2078941
Component name
IP to location API
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
There are a *lot* of Drupal location modules. Modules that use the MaxMind database. Modules that give you the location for an IP address. And they all have one thing in common. They all expect you to be looking up the location of the current visitor. And they expect you to be doing that on every page they visit.
Give me an API any day. An API, where I can say "Hey, what's the location for 89.233.206.124?" and it's all "Yo, that's Stockholm dude. 18.0167, 59.3667, that's where you're looking for." No current users, no sessions, no messing.
For example
$ip_address = "89.233.206.124";
$location = iptolocation__get_location($ip_address);
print_r($location);
Gives you:
stdClass Object
(
[lon] => 18.0167
[lat] => 59.3667
)
Dependencies
- PHP 5.3.10 or greater (the libraries use the
usekeyword). - X Autoload module
- Libraries API module
- GeoIP2 library from MaxMind
- MaxMind DB Reader library
