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

C++ 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
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

 

 

 

(C++) ipdata.co IPv4 Geolocation Lookup

See more Geolocation Examples

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

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <CkHttp.h>
#include <CkJsonObject.h>

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

    CkHttp http;

    const char *jsonStr = http.quickGetStr("https://api.ipdata.co/149.250.207.170?api-key=MY_API_KEY");
    if (http.get_LastMethodSuccess() == false) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    CkJsonObject json;
    json.put_EmitCompact(false);
    bool success = json.Load(jsonStr);

    std::cout << json.emit() << "\r\n";

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

    const char *ip = 0;
    bool is_eu;
    const char *city = 0;
    const char *region = 0;
    const char *region_code = 0;
    const char *country_name = 0;
    const char *country_code = 0;
    const char *continent_name = 0;
    const char *continent_code = 0;
    const char *latitude = 0;
    const char *longitude = 0;
    const char *asn = 0;
    const char *organisation = 0;
    const char *postal = 0;
    const char *calling_code = 0;
    const char *flag = 0;
    const char *emoji_flag = 0;
    const char *emoji_unicode = 0;
    const char *currencyName = 0;
    const char *currencyCode = 0;
    const char *currencySymbol = 0;
    const char *currencyNative = 0;
    const char *currencyPlural = 0;
    const char *time_zoneName = 0;
    const char *time_zoneAbbr = 0;
    const char *time_zoneOffset = 0;
    bool time_zoneIs_dst;
    const char *time_zoneCurrent_time = 0;
    bool threatIs_tor;
    bool threatIs_proxy;
    bool threatIs_anonymous;
    bool threatIs_known_attacker;
    bool threatIs_known_abuser;
    bool threatIs_threat;
    bool threatIs_bogon;
    const char *count = 0;
    int i;
    int count_i;
    const char *name = 0;
    const char *native = 0;

    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");
    while (i < count_i) {
        json.put_I(i);
        name = json.stringOf("languages[i].name");
        native = json.stringOf("languages[i].native");
        i = i + 1;
    }
    }

 

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