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
(Visual FoxPro) ipstack.com IPv4 Geolocation LookupDemonstrates how to lookup Geolocation data for an IPv4 address using the ipstack.com REST API.
LOCAL loHttp LOCAL lcJsonStr LOCAL loJson LOCAL lnSuccess LOCAL lcIp LOCAL lcV_type LOCAL lcContinent_code LOCAL lcContinent_name LOCAL lcCountry_code LOCAL lcCountry_name LOCAL lcRegion_code LOCAL lcRegion_name LOCAL lcCity LOCAL lcZip LOCAL lcLatitude LOCAL lcLongitude LOCAL lcLocationGeoname_id LOCAL lcLocationCapital LOCAL lcLocationCountry_flag LOCAL lcLocationCountry_flag_emoji LOCAL lcLocationCountry_flag_emoji_unicode LOCAL lcLocationCalling_code LOCAL lnLocationIs_eu LOCAL i LOCAL lnCount_i LOCAL lcCode LOCAL lcName LOCAL lcNative * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * Lookup an IPv4 address: 149.250.207.170 (this was a randomly chosen address) lcJsonStr = loHttp.QuickGetStr("http://api.ipstack.com/149.250.207.170?access_key=YOUR_ACCESS_KEY") IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.EmitCompact = 0 lnSuccess = loJson.Load(lcJsonStr) ? loJson.Emit() * 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 * } * } lcIp = loJson.StringOf("ip") lcV_type = loJson.StringOf("type") lcContinent_code = loJson.StringOf("continent_code") lcContinent_name = loJson.StringOf("continent_name") lcCountry_code = loJson.StringOf("country_code") lcCountry_name = loJson.StringOf("country_name") lcRegion_code = loJson.StringOf("region_code") lcRegion_name = loJson.StringOf("region_name") lcCity = loJson.StringOf("city") lcZip = loJson.StringOf("zip") lcLatitude = loJson.StringOf("latitude") lcLongitude = loJson.StringOf("longitude") lcLocationGeoname_id = loJson.StringOf("location.geoname_id") lcLocationCapital = loJson.StringOf("location.capital") lcLocationCountry_flag = loJson.StringOf("location.country_flag") lcLocationCountry_flag_emoji = loJson.StringOf("location.country_flag_emoji") lcLocationCountry_flag_emoji_unicode = loJson.StringOf("location.country_flag_emoji_unicode") lcLocationCalling_code = loJson.StringOf("location.calling_code") lnLocationIs_eu = loJson.BoolOf("location.is_eu") i = 0 lnCount_i = loJson.SizeOfArray("location.languages") DO WHILE i < lnCount_i loJson.I = i lcCode = loJson.StringOf("location.languages[i].code") lcName = loJson.StringOf("location.languages[i].name") lcNative = loJson.StringOf("location.languages[i].native") i = i + 1 ENDDO RELEASE loHttp RELEASE loJson |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.