Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Go Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Go) ipdata.co IPv4 Geolocation Lookup

Demonstrates how to lookup Geolocation data for an IPv4 address using the ipdata.co API.

Chilkat Go Downloads

Go Package for Windows, Linux, Alpine Linux,
MAC OS X, Solaris, FreeBSD, OpenBSD,
Raspberry Pi and other single board computers

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

    http := chilkat.NewHttp()

    jsonStr := http.QuickGetStr("https://api.ipdata.co/149.250.207.170?api-key=MY_API_KEY")
    if http.LastMethodSuccess() == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        return
    }

    json := chilkat.NewJsonObject()
    json.SetEmitCompact(false)
    success := json.Load(*jsonStr)

    fmt.Println(*json.Emit())

    // 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"
    // }

    var ip *string = new(string)
    var is_eu bool
    var city *string = new(string)
    var region *string = new(string)
    var region_code *string = new(string)
country_    var name *string = new(string)
    var country_code *string = new(string)
continent_    var name *string = new(string)
    var continent_code *string = new(string)
    var latitude *string = new(string)
    var longitude *string = new(string)
    var asn *string = new(string)
    var organisation *string = new(string)
    var postal *string = new(string)
    var calling_code *string = new(string)
    var flag *string = new(string)
emoji_    var flag *string = new(string)
    var emoji_unicode *string = new(string)
    var currencyName *string = new(string)
    var currencyCode *string = new(string)
    var currencySymbol *string = new(string)
    var currencyNative *string = new(string)
    var currencyPlural *string = new(string)
    var time_zoneName *string = new(string)
    var time_zoneAbbr *string = new(string)
    var time_zoneOffset *string = new(string)
    var time_zoneIs_dst bool
    var time_zoneCurrent_time *string = new(string)
    var threatIs_tor bool
    var threatIs_proxy bool
    var threatIs_anonymous bool
    var threatIs_known_attacker bool
    var threatIs_known_abuser bool
    var threatIs_threat bool
    var threatIs_bogon bool
    var count *string = new(string)
    var i int
    var count_i int
    var name *string = new(string)
    var native *string = new(string)

    ip = json.StringOf("ip")
    is_eu = json.BoolOf("is_eu")
    city = json.StringOf("city")
    region = json.StringOf("region")
    region_code = json.StringOf("region_code")
    country_name = json.StringOf("country_name")
    country_code = json.StringOf("country_code")
    continent_name = json.StringOf("continent_name")
    continent_code = json.StringOf("continent_code")
    latitude = json.StringOf("latitude")
    longitude = json.StringOf("longitude")
    asn = json.StringOf("asn")
    organisation = json.StringOf("organisation")
    postal = json.StringOf("postal")
    calling_code = json.StringOf("calling_code")
    flag = json.StringOf("flag")
    emoji_flag = json.StringOf("emoji_flag")
    emoji_unicode = json.StringOf("emoji_unicode")
    currencyName = json.StringOf("currency.name")
    currencyCode = json.StringOf("currency.code")
    currencySymbol = json.StringOf("currency.symbol")
    currencyNative = json.StringOf("currency.native")
    currencyPlural = json.StringOf("currency.plural")
    time_zoneName = json.StringOf("time_zone.name")
    time_zoneAbbr = json.StringOf("time_zone.abbr")
    time_zoneOffset = json.StringOf("time_zone.offset")
    time_zoneIs_dst = json.BoolOf("time_zone.is_dst")
    time_zoneCurrent_time = json.StringOf("time_zone.current_time")
    threatIs_tor = json.BoolOf("threat.is_tor")
    threatIs_proxy = json.BoolOf("threat.is_proxy")
    threatIs_anonymous = json.BoolOf("threat.is_anonymous")
    threatIs_known_attacker = json.BoolOf("threat.is_known_attacker")
    threatIs_known_abuser = json.BoolOf("threat.is_known_abuser")
    threatIs_threat = json.BoolOf("threat.is_threat")
    threatIs_bogon = json.BoolOf("threat.is_bogon")
    count = json.StringOf("count")
    i = 0
    count_i = json.SizeOfArray("languages")
    for i < count_i {
        json.SetI(i)
        name = json.StringOf("languages[i].name")
        native = json.StringOf("languages[i].native")
        i = i + 1
    }


    http.DisposeHttp()
    json.DisposeJsonObject()

 

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