Diese Daten können über die Bibliotheken von IP2Location ermittelt werden. Entwickler können die zur Verfügung gestellten APIs benutzen um die im binären Format vorliegenden Datenbanken abzufragen.
Folgendes wird dazu benötigt:
- IP2Location C API Bibliothek (Download: http://www.ip2location.com/c.htm)
- Ruby
- GNU make oder ein vergleichbares make (Windows können ggf. auf Cygwin aufbauen)
Installation:
[bash]
ruby extconf.rb –with-libIP2Location-lib=<path to C API lib> –with-includeIP2Location-include=<path to C API lib>
# Beispiel: ruby extconf.rb –with-libIP2Location-lib=..C-IP2Location-3.0.0libIP2Location –with-includeIP2Location-include=..C-IP2Location-3.0.0libIP2Location
make
[/bash]
Sourcecode Beispiel
[ruby]
require ‚IP2Location‘
IP2LocObj = IP2Location.new()
IP2LocObj.open("data/IP-COUNTRY-SAMPLE.BIN")
rec = IP2LocObj.get_all("12.34.56.78")
puts rec.country_short
puts rec.country_long
puts rec.city
puts rec.region
puts rec.isp
puts rec.latitude
puts rec.longitude
puts rec.domain
puts rec.zipcode
puts rec.timezone
puts rec.netspeed
puts rec.iddcode
puts rec.areacode
puts rec.weatherstationcode
puts rec.weatherstationname
[/ruby]