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
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) ipstack.com IPv4 Geolocation Lookup

Demonstrates how to lookup Geolocation data for an IPv4 address using the ipstack.com REST API.

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 sIp
    String sV_type
    String sContinent_code
    String sContinent_name
    String sCountry_code
    String sCountry_name
    String sRegion_code
    String sRegion_name
    String sCity
    String sZip
    String sLatitude
    String sLongitude
    String sLocationGeoname_id
    String sLocationCapital
    String sLocationCountry_flag
    String sLocationCountry_flag_emoji
    String sLocationCountry_flag_emoji_unicode
    String sLocationCalling_code
    Boolean iLocationIs_eu
    Integer i
    Integer iCount_i
    String sCode
    String sName
    String sNative
    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

    // Lookup an IPv4 address: 149.250.207.170  (this was a randomly chosen address)
    Get ComQuickGetStr Of hoHttp "http://api.ipstack.com/149.250.207.170?access_key=YOUR_ACCESS_KEY" 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

    // {
    //   "ip": "149.250.207.170",
    //   "type": "ipv4",
    //   "continent_code": "EU",
    //   "continent_name": "Europe",
    //   "country_code": "DE",
    //   "country_name": "Germany",
    //   "region_code": null,
    //   "region_name": null,
    //   "city": null,
    //   "zip": null,
    //   "latitude": 51.2993,
    //   "longitude": 9.491,
    //   "location": {
    //     "geoname_id": null,
    //     "capital": "Berlin",
    //     "languages": [
    //       {
    //         "code": "de",
    //         "name": "German",
    //         "native": "Deutsch"
    //       }
    //     ],
    //     "country_flag": "http:\/\/assets.ipstack.com\/flags\/de.svg",
    //     "country_flag_emoji": "\ud83c\udde9\ud83c\uddea",
    //     "country_flag_emoji_unicode": "U+1F1E9 U+1F1EA",
    //     "calling_code": "49",
    //     "is_eu": true
    //   }
    // }

    Get ComStringOf Of hoJson "ip" To sIp
    Get ComStringOf Of hoJson "type" To sV_type
    Get ComStringOf Of hoJson "continent_code" To sContinent_code
    Get ComStringOf Of hoJson "continent_name" To sContinent_name
    Get ComStringOf Of hoJson "country_code" To sCountry_code
    Get ComStringOf Of hoJson "country_name" To sCountry_name
    Get ComStringOf Of hoJson "region_code" To sRegion_code
    Get ComStringOf Of hoJson "region_name" To sRegion_name
    Get ComStringOf Of hoJson "city" To sCity
    Get ComStringOf Of hoJson "zip" To sZip
    Get ComStringOf Of hoJson "latitude" To sLatitude
    Get ComStringOf Of hoJson "longitude" To sLongitude
    Get ComStringOf Of hoJson "location.geoname_id" To sLocationGeoname_id
    Get ComStringOf Of hoJson "location.capital" To sLocationCapital
    Get ComStringOf Of hoJson "location.country_flag" To sLocationCountry_flag
    Get ComStringOf Of hoJson "location.country_flag_emoji" To sLocationCountry_flag_emoji
    Get ComStringOf Of hoJson "location.country_flag_emoji_unicode" To sLocationCountry_flag_emoji_unicode
    Get ComStringOf Of hoJson "location.calling_code" To sLocationCalling_code
    Get ComBoolOf Of hoJson "location.is_eu" To iLocationIs_eu
    Move 0 To i
    Get ComSizeOfArray Of hoJson "location.languages" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "location.languages[i].code" To sCode
        Get ComStringOf Of hoJson "location.languages[i].name" To sName
        Get ComStringOf Of hoJson "location.languages[i].native" To sNative
        Move (i + 1) To i
    Loop



End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.