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

AutoIt 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

 

 

 

(AutoIt) 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

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")

; Lookup an IPv4 address: 149.250.207.170  (this was a randomly chosen address)
Local $sJsonStr = $oHttp.QuickGetStr("http://api.ipstack.com/149.250.207.170?access_key=YOUR_ACCESS_KEY")
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.EmitCompact = False
Local $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

; {
;   "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
;   }
; }

Local $sIp
Local $sV_type
Local $sContinent_code
Local $sContinent_name
Local $sCountry_code
Local $sCountry_name
Local $sRegion_code
Local $sRegion_name
Local $sCity
Local $sZip
Local $sLatitude
Local $sLongitude
Local $sLocationGeoname_id
Local $sLocationCapital
Local $sLocationCountry_flag
Local $sLocationCountry_flag_emoji
Local $sLocationCountry_flag_emoji_unicode
Local $sLocationCalling_code
Local $bLocationIs_eu
Local $i
Local $iCount_i
Local $sCode
Local $sName
Local $sNative

$sIp = $oJson.StringOf("ip")
$sV_type = $oJson.StringOf("type")
$sContinent_code = $oJson.StringOf("continent_code")
$sContinent_name = $oJson.StringOf("continent_name")
$sCountry_code = $oJson.StringOf("country_code")
$sCountry_name = $oJson.StringOf("country_name")
$sRegion_code = $oJson.StringOf("region_code")
$sRegion_name = $oJson.StringOf("region_name")
$sCity = $oJson.StringOf("city")
$sZip = $oJson.StringOf("zip")
$sLatitude = $oJson.StringOf("latitude")
$sLongitude = $oJson.StringOf("longitude")
$sLocationGeoname_id = $oJson.StringOf("location.geoname_id")
$sLocationCapital = $oJson.StringOf("location.capital")
$sLocationCountry_flag = $oJson.StringOf("location.country_flag")
$sLocationCountry_flag_emoji = $oJson.StringOf("location.country_flag_emoji")
$sLocationCountry_flag_emoji_unicode = $oJson.StringOf("location.country_flag_emoji_unicode")
$sLocationCalling_code = $oJson.StringOf("location.calling_code")
$bLocationIs_eu = $oJson.BoolOf("location.is_eu")
$i = 0
$iCount_i = $oJson.SizeOfArray("location.languages")
While $i < $iCount_i
    $oJson.I = $i
    $sCode = $oJson.StringOf("location.languages[i].code")
    $sName = $oJson.StringOf("location.languages[i].name")
    $sNative = $oJson.StringOf("location.languages[i].native")
    $i = $i + 1
Wend

 

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