Lianja
Lianja
MaxMind IPv4 Geolocation Lookup
See more Geolocation Examples
Demonstrates how to lookup Geolocation data for an IPv4 address using the MaxMind GeoIP2 Precision Web Service.Chilkat Lianja Downloads
llSuccess = .F.
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loHttp.Login = "MAXMIND_ACCOUNT_ID"
loHttp.Password = "MAXMIND_LICENSE_KEY"
loHttp.Accept = "application/json"
// Lookup an IPv4 address: 149.250.207.170 (this was a randomly chosen address)
lcJsonStr = loHttp.QuickGetStr("https://geoip.maxmind.com/geoip/v2.1/country/149.250.207.170")
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
return
endif
loJson = createobject("CkJsonObject")
loJson.EmitCompact = .F.
llSuccess = loJson.Load(lcJsonStr)
? loJson.Emit()
// Sample output:
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// {
// "continent": {
// "code": "EU",
// "geoname_id": 6255148,
// "names": {
// "ja": "?????",
// "pt-BR": "Europa",
// "ru": "??????",
// "zh-CN": "??",
// "de": "Europa",
// "en": "Europe",
// "es": "Europa",
// "fr": "Europe"
// }
// },
// "country": {
// "is_in_european_union": true,
// "iso_code": "DE",
// "geoname_id": 2921044,
// "names": {
// "fr": "Allemagne",
// "ja": "????????",
// "pt-BR": "Alemanha",
// "ru": "????????",
// "zh-CN": "??",
// "de": "Deutschland",
// "en": "Germany",
// "es": "Alemania"
// }
// },
// "maxmind": {
// "queries_remaining": 49999
// },
// "registered_country": {
// "is_in_european_union": true,
// "iso_code": "DE",
// "geoname_id": 2921044,
// "names": {
// "es": "Alemania",
// "fr": "Allemagne",
// "ja": "????????",
// "pt-BR": "Alemanha",
// "ru": "????????",
// "zh-CN": "??",
// "de": "Deutschland",
// "en": "Germany"
// }
// },
// "traits": {
// "ip_address": "149.250.207.170"
// }
// }
//
//
lcContinentCode = loJson.StringOf("continent.code")
lnContinentGeoname_id = loJson.IntOf("continent.geoname_id")
lcContinentNamesJa = loJson.StringOf("continent.names.ja")
lcContinentNamesPt_BR = loJson.StringOf("continent.names.pt-BR")
lcContinentNamesRu = loJson.StringOf("continent.names.ru")
lcContinentNamesZh_CN = loJson.StringOf("continent.names.zh-CN")
lcContinentNamesDe = loJson.StringOf("continent.names.de")
lcContinentNamesEn = loJson.StringOf("continent.names.en")
lcContinentNamesEs = loJson.StringOf("continent.names.es")
lcContinentNamesFr = loJson.StringOf("continent.names.fr")
llCountryIs_in_european_union = loJson.BoolOf("country.is_in_european_union")
lcCountryIso_code = loJson.StringOf("country.iso_code")
lnCountryGeoname_id = loJson.IntOf("country.geoname_id")
lcCountryNamesFr = loJson.StringOf("country.names.fr")
lcCountryNamesJa = loJson.StringOf("country.names.ja")
lcCountryNamesPt_BR = loJson.StringOf("country.names.pt-BR")
lcCountryNamesRu = loJson.StringOf("country.names.ru")
lcCountryNamesZh_CN = loJson.StringOf("country.names.zh-CN")
lcCountryNamesDe = loJson.StringOf("country.names.de")
lcCountryNamesEn = loJson.StringOf("country.names.en")
lcCountryNamesEs = loJson.StringOf("country.names.es")
lnMaxmindQueries_remaining = loJson.IntOf("maxmind.queries_remaining")
llRegistered_countryIs_in_european_union = loJson.BoolOf("registered_country.is_in_european_union")
lcRegistered_countryIso_code = loJson.StringOf("registered_country.iso_code")
lnRegistered_countryGeoname_id = loJson.IntOf("registered_country.geoname_id")
lcRegistered_countryNamesEs = loJson.StringOf("registered_country.names.es")
lcRegistered_countryNamesFr = loJson.StringOf("registered_country.names.fr")
lcRegistered_countryNamesJa = loJson.StringOf("registered_country.names.ja")
lcRegistered_countryNamesPt_BR = loJson.StringOf("registered_country.names.pt-BR")
lcRegistered_countryNamesRu = loJson.StringOf("registered_country.names.ru")
lcRegistered_countryNamesZh_CN = loJson.StringOf("registered_country.names.zh-CN")
lcRegistered_countryNamesDe = loJson.StringOf("registered_country.names.de")
lcRegistered_countryNamesEn = loJson.StringOf("registered_country.names.en")
lcTraitsIp_address = loJson.StringOf("traits.ip_address")
release loHttp
release loJson