Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) MaxMind IPv4 Geolocation LookupDemonstrates how to lookup Geolocation data for an IPv4 address using the MaxMind GeoIP2 Precision Web Service.
LOCAL loHttp LOCAL lcJsonStr LOCAL loJson LOCAL lnSuccess LOCAL lcContinentCode LOCAL lnContinentGeoname_id LOCAL lcContinentNamesJa LOCAL lcContinentNamesPt_BR LOCAL lcContinentNamesRu LOCAL lcContinentNamesZh_CN LOCAL lcContinentNamesDe LOCAL lcContinentNamesEn LOCAL lcContinentNamesEs LOCAL lcContinentNamesFr LOCAL lnCountryIs_in_european_union LOCAL lcCountryIso_code LOCAL lnCountryGeoname_id LOCAL lcCountryNamesFr LOCAL lcCountryNamesJa LOCAL lcCountryNamesPt_BR LOCAL lcCountryNamesRu LOCAL lcCountryNamesZh_CN LOCAL lcCountryNamesDe LOCAL lcCountryNamesEn LOCAL lcCountryNamesEs LOCAL lnMaxmindQueries_remaining LOCAL lnRegistered_countryIs_in_european_union LOCAL lcRegistered_countryIso_code LOCAL lnRegistered_countryGeoname_id LOCAL lcRegistered_countryNamesEs LOCAL lcRegistered_countryNamesFr LOCAL lcRegistered_countryNamesJa LOCAL lcRegistered_countryNamesPt_BR LOCAL lcRegistered_countryNamesRu LOCAL lcRegistered_countryNamesZh_CN LOCAL lcRegistered_countryNamesDe LOCAL lcRegistered_countryNamesEn LOCAL lcTraitsIp_address * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') 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 = 0) THEN ? loHttp.LastErrorText RELEASE loHttp CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.EmitCompact = 0 lnSuccess = 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") lnCountryIs_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") lnRegistered_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 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.