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
(Tcl) ipdata.co IPv4 Geolocation LookupSee more Geolocation ExamplesDemonstrates how to lookup Geolocation data for an IPv4 address using the ipdata.co API.
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] set jsonStr [CkHttp_quickGetStr $http "https://api.ipdata.co/149.250.207.170?api-key=MY_API_KEY"] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http exit } set json [new_CkJsonObject] CkJsonObject_put_EmitCompact $json 0 set success [CkJsonObject_Load $json $jsonStr] puts [CkJsonObject_emit $json] # Sample output: # Use this online tool to generate parsing code from sample JSON: # Generate Parsing Code from JSON # { # "ip": "149.250.207.170", # "is_eu": true, # "city": null, # "region": null, # "region_code": null, # "country_name": "Germany", # "country_code": "DE", # "continent_name": "Europe", # "continent_code": "EU", # "latitude": 51.2993, # "longitude": 9.491, # "asn": "AS15854", # "organisation": "EntServ Deutschland GmbH", # "postal": null, # "calling_code": "49", # "flag": "https://ipdata.co/flags/de.png", # "emoji_flag": "\ud83c\udde9\ud83c\uddea", # "emoji_unicode": "U+1F1E9 U+1F1EA", # "languages": [ # { # "name": "German", # "native": "Deutsch" # } # ], # "currency": { # "name": "Euro", # "code": "EUR", # "symbol": "\u20ac", # "native": "\u20ac", # "plural": "euros" # }, # "time_zone": { # "name": "Europe/Berlin", # "abbr": "CEST", # "offset": "+0200", # "is_dst": true, # "current_time": "2019-04-20T23:54:30.715507+02:00" # }, # "threat": { # "is_tor": false, # "is_proxy": false, # "is_anonymous": false, # "is_known_attacker": false, # "is_known_abuser": false, # "is_threat": false, # "is_bogon": false # }, # "count": "2" # } set ip [CkJsonObject_stringOf $json "ip"] set is_eu [CkJsonObject_BoolOf $json "is_eu"] set city [CkJsonObject_stringOf $json "city"] set region [CkJsonObject_stringOf $json "region"] set region_code [CkJsonObject_stringOf $json "region_code"] set country_name [CkJsonObject_stringOf $json "country_name"] set country_code [CkJsonObject_stringOf $json "country_code"] set continent_name [CkJsonObject_stringOf $json "continent_name"] set continent_code [CkJsonObject_stringOf $json "continent_code"] set latitude [CkJsonObject_stringOf $json "latitude"] set longitude [CkJsonObject_stringOf $json "longitude"] set asn [CkJsonObject_stringOf $json "asn"] set organisation [CkJsonObject_stringOf $json "organisation"] set postal [CkJsonObject_stringOf $json "postal"] set calling_code [CkJsonObject_stringOf $json "calling_code"] set flag [CkJsonObject_stringOf $json "flag"] set emoji_flag [CkJsonObject_stringOf $json "emoji_flag"] set emoji_unicode [CkJsonObject_stringOf $json "emoji_unicode"] set currencyName [CkJsonObject_stringOf $json "currency.name"] set currencyCode [CkJsonObject_stringOf $json "currency.code"] set currencySymbol [CkJsonObject_stringOf $json "currency.symbol"] set currencyNative [CkJsonObject_stringOf $json "currency.native"] set currencyPlural [CkJsonObject_stringOf $json "currency.plural"] set time_zoneName [CkJsonObject_stringOf $json "time_zone.name"] set time_zoneAbbr [CkJsonObject_stringOf $json "time_zone.abbr"] set time_zoneOffset [CkJsonObject_stringOf $json "time_zone.offset"] set time_zoneIs_dst [CkJsonObject_BoolOf $json "time_zone.is_dst"] set time_zoneCurrent_time [CkJsonObject_stringOf $json "time_zone.current_time"] set threatIs_tor [CkJsonObject_BoolOf $json "threat.is_tor"] set threatIs_proxy [CkJsonObject_BoolOf $json "threat.is_proxy"] set threatIs_anonymous [CkJsonObject_BoolOf $json "threat.is_anonymous"] set threatIs_known_attacker [CkJsonObject_BoolOf $json "threat.is_known_attacker"] set threatIs_known_abuser [CkJsonObject_BoolOf $json "threat.is_known_abuser"] set threatIs_threat [CkJsonObject_BoolOf $json "threat.is_threat"] set threatIs_bogon [CkJsonObject_BoolOf $json "threat.is_bogon"] set count [CkJsonObject_stringOf $json "count"] set i 0 set count_i [CkJsonObject_SizeOfArray $json "languages"] while {$i < $count_i} { CkJsonObject_put_I $json $i set name [CkJsonObject_stringOf $json "languages[i].name"] set native [CkJsonObject_stringOf $json "languages[i].native"] set i [expr $i + 1] } delete_CkHttp $http delete_CkJsonObject $json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.