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
(DataFlex) MaxMind IPv4 Geolocation LookupDemonstrates how to lookup Geolocation data for an IPv4 address using the MaxMind GeoIP2 Precision Web Service.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp String sJsonStr Handle hoJson Boolean iSuccess String sContinentCode Integer iContinentGeoname_id String sContinentNamesJa String sContinentNamesPt_BR String sContinentNamesRu String sContinentNamesZh_CN String sContinentNamesDe String sContinentNamesEn String sContinentNamesEs String sContinentNamesFr Boolean iCountryIs_in_european_union String sCountryIso_code Integer iCountryGeoname_id String sCountryNamesFr String sCountryNamesJa String sCountryNamesPt_BR String sCountryNamesRu String sCountryNamesZh_CN String sCountryNamesDe String sCountryNamesEn String sCountryNamesEs Integer iMaxmindQueries_remaining Boolean iRegistered_countryIs_in_european_union String sRegistered_countryIso_code Integer iRegistered_countryGeoname_id String sRegistered_countryNamesEs String sRegistered_countryNamesFr String sRegistered_countryNamesJa String sRegistered_countryNamesPt_BR String sRegistered_countryNamesRu String sRegistered_countryNamesZh_CN String sRegistered_countryNamesDe String sRegistered_countryNamesEn String sTraitsIp_address String sTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Set ComLogin Of hoHttp To "MAXMIND_ACCOUNT_ID" Set ComPassword Of hoHttp To "MAXMIND_LICENSE_KEY" Set ComAccept Of hoHttp To "application/json" // Lookup an IPv4 address: 149.250.207.170 (this was a randomly chosen address) Get ComQuickGetStr Of hoHttp "https://geoip.maxmind.com/geoip/v2.1/country/149.250.207.170" To sJsonStr Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Set ComEmitCompact Of hoJson To False Get ComLoad Of hoJson sJsonStr To iSuccess Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // 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" // } // } // // Get ComStringOf Of hoJson "continent.code" To sContinentCode Get ComIntOf Of hoJson "continent.geoname_id" To iContinentGeoname_id Get ComStringOf Of hoJson "continent.names.ja" To sContinentNamesJa Get ComStringOf Of hoJson "continent.names.pt-BR" To sContinentNamesPt_BR Get ComStringOf Of hoJson "continent.names.ru" To sContinentNamesRu Get ComStringOf Of hoJson "continent.names.zh-CN" To sContinentNamesZh_CN Get ComStringOf Of hoJson "continent.names.de" To sContinentNamesDe Get ComStringOf Of hoJson "continent.names.en" To sContinentNamesEn Get ComStringOf Of hoJson "continent.names.es" To sContinentNamesEs Get ComStringOf Of hoJson "continent.names.fr" To sContinentNamesFr Get ComBoolOf Of hoJson "country.is_in_european_union" To iCountryIs_in_european_union Get ComStringOf Of hoJson "country.iso_code" To sCountryIso_code Get ComIntOf Of hoJson "country.geoname_id" To iCountryGeoname_id Get ComStringOf Of hoJson "country.names.fr" To sCountryNamesFr Get ComStringOf Of hoJson "country.names.ja" To sCountryNamesJa Get ComStringOf Of hoJson "country.names.pt-BR" To sCountryNamesPt_BR Get ComStringOf Of hoJson "country.names.ru" To sCountryNamesRu Get ComStringOf Of hoJson "country.names.zh-CN" To sCountryNamesZh_CN Get ComStringOf Of hoJson "country.names.de" To sCountryNamesDe Get ComStringOf Of hoJson "country.names.en" To sCountryNamesEn Get ComStringOf Of hoJson "country.names.es" To sCountryNamesEs Get ComIntOf Of hoJson "maxmind.queries_remaining" To iMaxmindQueries_remaining Get ComBoolOf Of hoJson "registered_country.is_in_european_union" To iRegistered_countryIs_in_european_union Get ComStringOf Of hoJson "registered_country.iso_code" To sRegistered_countryIso_code Get ComIntOf Of hoJson "registered_country.geoname_id" To iRegistered_countryGeoname_id Get ComStringOf Of hoJson "registered_country.names.es" To sRegistered_countryNamesEs Get ComStringOf Of hoJson "registered_country.names.fr" To sRegistered_countryNamesFr Get ComStringOf Of hoJson "registered_country.names.ja" To sRegistered_countryNamesJa Get ComStringOf Of hoJson "registered_country.names.pt-BR" To sRegistered_countryNamesPt_BR Get ComStringOf Of hoJson "registered_country.names.ru" To sRegistered_countryNamesRu Get ComStringOf Of hoJson "registered_country.names.zh-CN" To sRegistered_countryNamesZh_CN Get ComStringOf Of hoJson "registered_country.names.de" To sRegistered_countryNamesDe Get ComStringOf Of hoJson "registered_country.names.en" To sRegistered_countryNamesEn Get ComStringOf Of hoJson "traits.ip_address" To sTraitsIp_address End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.