AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.Login = "MAXMIND_ACCOUNT_ID"
$oHttp.Password = "MAXMIND_LICENSE_KEY"
$oHttp.Accept = "application/json"
; Lookup an IPv4 address: 149.250.207.170 (this was a randomly chosen address)
Local $sJsonStr = $oHttp.QuickGetStr("https://geoip.maxmind.com/geoip/v2.1/country/149.250.207.170")
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.EmitCompact = False
$bSuccess = $oJson.Load($sJsonStr)
ConsoleWrite($oJson.Emit() & @CRLF)
; 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"
; }
; }
;
;
Local $sContinentCode
Local $iContinentGeoname_id
Local $sContinentNamesJa
Local $sContinentNamesPt_BR
Local $sContinentNamesRu
Local $sContinentNamesZh_CN
Local $sContinentNamesDe
Local $sContinentNamesEn
Local $sContinentNamesEs
Local $sContinentNamesFr
Local $bCountryIs_in_european_union
Local $sCountryIso_code
Local $iCountryGeoname_id
Local $sCountryNamesFr
Local $sCountryNamesJa
Local $sCountryNamesPt_BR
Local $sCountryNamesRu
Local $sCountryNamesZh_CN
Local $sCountryNamesDe
Local $sCountryNamesEn
Local $sCountryNamesEs
Local $iMaxmindQueries_remaining
Local $bRegistered_countryIs_in_european_union
Local $sRegistered_countryIso_code
Local $iRegistered_countryGeoname_id
Local $sRegistered_countryNamesEs
Local $sRegistered_countryNamesFr
Local $sRegistered_countryNamesJa
Local $sRegistered_countryNamesPt_BR
Local $sRegistered_countryNamesRu
Local $sRegistered_countryNamesZh_CN
Local $sRegistered_countryNamesDe
Local $sRegistered_countryNamesEn
Local $sTraitsIp_address
$sContinentCode = $oJson.StringOf("continent.code")
$iContinentGeoname_id = $oJson.IntOf("continent.geoname_id")
$sContinentNamesJa = $oJson.StringOf("continent.names.ja")
$sContinentNamesPt_BR = $oJson.StringOf("continent.names.pt-BR")
$sContinentNamesRu = $oJson.StringOf("continent.names.ru")
$sContinentNamesZh_CN = $oJson.StringOf("continent.names.zh-CN")
$sContinentNamesDe = $oJson.StringOf("continent.names.de")
$sContinentNamesEn = $oJson.StringOf("continent.names.en")
$sContinentNamesEs = $oJson.StringOf("continent.names.es")
$sContinentNamesFr = $oJson.StringOf("continent.names.fr")
$bCountryIs_in_european_union = $oJson.BoolOf("country.is_in_european_union")
$sCountryIso_code = $oJson.StringOf("country.iso_code")
$iCountryGeoname_id = $oJson.IntOf("country.geoname_id")
$sCountryNamesFr = $oJson.StringOf("country.names.fr")
$sCountryNamesJa = $oJson.StringOf("country.names.ja")
$sCountryNamesPt_BR = $oJson.StringOf("country.names.pt-BR")
$sCountryNamesRu = $oJson.StringOf("country.names.ru")
$sCountryNamesZh_CN = $oJson.StringOf("country.names.zh-CN")
$sCountryNamesDe = $oJson.StringOf("country.names.de")
$sCountryNamesEn = $oJson.StringOf("country.names.en")
$sCountryNamesEs = $oJson.StringOf("country.names.es")
$iMaxmindQueries_remaining = $oJson.IntOf("maxmind.queries_remaining")
$bRegistered_countryIs_in_european_union = $oJson.BoolOf("registered_country.is_in_european_union")
$sRegistered_countryIso_code = $oJson.StringOf("registered_country.iso_code")
$iRegistered_countryGeoname_id = $oJson.IntOf("registered_country.geoname_id")
$sRegistered_countryNamesEs = $oJson.StringOf("registered_country.names.es")
$sRegistered_countryNamesFr = $oJson.StringOf("registered_country.names.fr")
$sRegistered_countryNamesJa = $oJson.StringOf("registered_country.names.ja")
$sRegistered_countryNamesPt_BR = $oJson.StringOf("registered_country.names.pt-BR")
$sRegistered_countryNamesRu = $oJson.StringOf("registered_country.names.ru")
$sRegistered_countryNamesZh_CN = $oJson.StringOf("registered_country.names.zh-CN")
$sRegistered_countryNamesDe = $oJson.StringOf("registered_country.names.de")
$sRegistered_countryNamesEn = $oJson.StringOf("registered_country.names.en")
$sTraitsIp_address = $oJson.StringOf("traits.ip_address")