Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) MaxMind IPv4 Geolocation Lookup

Demonstrates how to lookup Geolocation data for an IPv4 address using the MaxMind GeoIP2 Precision Web Service.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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.