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
(Unicode C) RDAP Domain Lookup using rdap.orgDemonstrates doing an RDAP domain lookup using the rdap.org public RDAP server.
#include <C_CkHttpW.h> #include <C_CkStringBuilderW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpW http; HCkStringBuilderW sbResponse; BOOL success; int statusCode; HCkJsonObjectW json; const wchar_t *value; const wchar_t *rel; const wchar_t *href; const wchar_t *v_type; const wchar_t *strVal; int j; int count_j; const wchar_t *identifier; int k; int count_k; HCkJsonObjectW json1; int i1; int count_i1; int j1; int count_j1; const wchar_t *eventAction; const wchar_t *eventDate; const wchar_t *title; const wchar_t *objectClassName; const wchar_t *handle; const wchar_t *ldhName; BOOL DelegationSigned; int i; int count_i; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); // Send HTTP requests to https://rdap.org/<type>/<object>, where <type> is the object type (one of domain, ip, autnum, entity etc) // and <object> is the object identifier (eg example.com, 192.168.0.1, 64496, etc). // For example, here's a lookup for "oracle.com" sbResponse = CkStringBuilderW_Create(); success = CkHttpW_QuickGetSb(http,L"https://rdap.org/domain/oracle.com",sbResponse); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponse); return; } statusCode = CkHttpW_getLastStatus(http); if (statusCode != 200) { wprintf(L"Error response:\n"); wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponse)); wprintf(L"status code: %d\n",statusCode); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponse); return; } // Load the JSON response and examine.. // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON json = CkJsonObjectW_Create(); CkJsonObjectW_LoadSb(json,sbResponse); CkJsonObjectW_putEmitCompact(json,FALSE); wprintf(L"%s\n",CkJsonObjectW_emit(json)); // Here's a sample response, and the parsing code generated from the above online tool follows.. // { // "objectClassName": "domain", // "handle": "607513_DOMAIN_COM-VRSN", // "ldhName": "ORACLE.COM", // "links": [ // { // "value": "https:\/\/rdap.verisign.com\/com\/v1\/domain\/ORACLE.COM", // "rel": "self", // "href": "https:\/\/rdap.verisign.com\/com\/v1\/domain\/ORACLE.COM", // "type": "application\/rdap+json" // }, // { // "value": "https:\/\/rdap.markmonitor.com\/rdap\/domain\/ORACLE.COM", // "rel": "related", // "href": "https:\/\/rdap.markmonitor.com\/rdap\/domain\/ORACLE.COM", // "type": "application\/rdap+json" // } // ], // "status": [ // "client delete prohibited", // "client transfer prohibited", // "client update prohibited", // "server delete prohibited", // "server transfer prohibited", // "server update prohibited" // ], // "entities": [ // { // "objectClassName": "entity", // "handle": "292", // "roles": [ // "registrar" // ], // "publicIds": [ // { // "type": "IANA Registrar ID", // "identifier": "292" // } // ], // "vcardArray": [ // "vcard", // [ // [ // "version", // {}, // "text", // "4.0" // ], // [ // "fn", // {}, // "text", // "MarkMonitor Inc." // ] // ] // ], // "entities": [ // { // "objectClassName": "entity", // "roles": [ // "abuse" // ], // "vcardArray": [ // "vcard", // [ // [ // "version", // {}, // "text", // "4.0" // ], // [ // "fn", // {}, // "text", // "" // ], // [ // "tel", // { // "type": "voice" // }, // "uri", // "tel:+1.2086851750" // ], // [ // "email", // {}, // "text", // "abusecomplaints@markmonitor.com" // ] // ] // ] // } // ] // } // ], // "events": [ // { // "eventAction": "registration", // "eventDate": "1988-12-02T05:00:00Z" // }, // { // "eventAction": "expiration", // "eventDate": "2025-12-01T05:00:00Z" // }, // { // "eventAction": "last changed", // "eventDate": "2024-10-30T09:32:52Z" // }, // { // "eventAction": "last update of RDAP database", // "eventDate": "2024-11-26T14:11:14Z" // } // ], // "secureDNS": { // "delegationSigned": false // }, // "nameservers": [ // { // "objectClassName": "nameserver", // "ldhName": "A1-160.AKAM.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "A11-66.AKAM.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "A13-65.AKAM.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "A18-67.AKAM.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "NS1.P201.DNS.ORACLECLOUD.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "NS2.P201.DNS.ORACLECLOUD.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "NS3.P201.DNS.ORACLECLOUD.NET" // }, // { // "objectClassName": "nameserver", // "ldhName": "NS4.P201.DNS.ORACLECLOUD.NET" // } // ], // "rdapConformance": [ // "rdap_level_0", // "icann_rdap_technical_implementation_guide_0", // "icann_rdap_response_profile_0" // ], // "notices": [ // { // "title": "Terms of Use", // "description": [ // "Service subject to Terms of Use." // ], // "links": [ // { // "href": "https:\/\/www.verisign.com\/domain-names\/registration-data-access-protocol\/terms-service\/index.xhtml", // "type": "text\/html" // } // ] // }, // { // "title": "Status Codes", // "description": [ // "For more information on domain status codes, please visit https:\/\/icann.org\/epp" // ], // "links": [ // { // "href": "https:\/\/icann.org\/epp", // "type": "text\/html" // } // ] // }, // { // "title": "RDDS Inaccuracy Complaint Form", // "description": [ // "URL of the ICANN RDDS Inaccuracy Complaint Form: https:\/\/icann.org\/wicf" // ], // "links": [ // { // "href": "https:\/\/icann.org\/wicf", // "type": "text\/html" // } // ] // } // ] // } objectClassName = CkJsonObjectW_stringOf(json,L"objectClassName"); handle = CkJsonObjectW_stringOf(json,L"handle"); ldhName = CkJsonObjectW_stringOf(json,L"ldhName"); DelegationSigned = CkJsonObjectW_BoolOf(json,L"secureDNS.delegationSigned"); i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"links"); while (i < count_i) { CkJsonObjectW_putI(json,i); value = CkJsonObjectW_stringOf(json,L"links[i].value"); rel = CkJsonObjectW_stringOf(json,L"links[i].rel"); href = CkJsonObjectW_stringOf(json,L"links[i].href"); v_type = CkJsonObjectW_stringOf(json,L"links[i].type"); i = i + 1; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"status"); while (i < count_i) { CkJsonObjectW_putI(json,i); strVal = CkJsonObjectW_stringOf(json,L"status[i]"); i = i + 1; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"entities"); while (i < count_i) { CkJsonObjectW_putI(json,i); objectClassName = CkJsonObjectW_stringOf(json,L"entities[i].objectClassName"); handle = CkJsonObjectW_stringOf(json,L"entities[i].handle"); j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"entities[i].roles"); while (j < count_j) { CkJsonObjectW_putJ(json,j); strVal = CkJsonObjectW_stringOf(json,L"entities[i].roles[j]"); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"entities[i].publicIds"); while (j < count_j) { CkJsonObjectW_putJ(json,j); v_type = CkJsonObjectW_stringOf(json,L"entities[i].publicIds[j].type"); identifier = CkJsonObjectW_stringOf(json,L"entities[i].publicIds[j].identifier"); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"entities[i].vcardArray"); while (j < count_j) { CkJsonObjectW_putJ(json,j); strVal = CkJsonObjectW_stringOf(json,L"entities[i].vcardArray[j]"); k = 0; count_k = CkJsonObjectW_SizeOfArray(json,L"entities[i].vcardArray[j]"); while (k < count_k) { CkJsonObjectW_putK(json,k); json1 = CkJsonObjectW_ObjectOf(json,L"entities[i].vcardArray[j][k]"); i1 = 0; count_i1 = CkJsonObjectW_SizeOfArray(json1,L""); while (i1 < count_i1) { CkJsonObjectW_putI(json1,i1); strVal = CkJsonObjectW_stringOf(json1,L"[i]"); i1 = i1 + 1; } CkJsonObjectW_Dispose(json1); k = k + 1; } j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"entities[i].entities"); while (j < count_j) { CkJsonObjectW_putJ(json,j); objectClassName = CkJsonObjectW_stringOf(json,L"entities[i].entities[j].objectClassName"); k = 0; count_k = CkJsonObjectW_SizeOfArray(json,L"entities[i].entities[j].roles"); while (k < count_k) { CkJsonObjectW_putK(json,k); strVal = CkJsonObjectW_stringOf(json,L"entities[i].entities[j].roles[k]"); k = k + 1; } k = 0; count_k = CkJsonObjectW_SizeOfArray(json,L"entities[i].entities[j].vcardArray"); while (k < count_k) { CkJsonObjectW_putK(json,k); strVal = CkJsonObjectW_stringOf(json,L"entities[i].entities[j].vcardArray[k]"); json1 = CkJsonObjectW_ObjectOf(json,L"entities[i].entities[j].vcardArray[k]"); i1 = 0; count_i1 = CkJsonObjectW_SizeOfArray(json1,L""); while (i1 < count_i1) { CkJsonObjectW_putI(json1,i1); j1 = 0; count_j1 = CkJsonObjectW_SizeOfArray(json1,L"[i]"); while (j1 < count_j1) { CkJsonObjectW_putJ(json1,j1); strVal = CkJsonObjectW_stringOf(json1,L"[i][j]"); j1 = j1 + 1; } i1 = i1 + 1; } CkJsonObjectW_Dispose(json1); k = k + 1; } j = j + 1; } i = i + 1; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"events"); while (i < count_i) { CkJsonObjectW_putI(json,i); eventAction = CkJsonObjectW_stringOf(json,L"events[i].eventAction"); eventDate = CkJsonObjectW_stringOf(json,L"events[i].eventDate"); i = i + 1; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"nameservers"); while (i < count_i) { CkJsonObjectW_putI(json,i); objectClassName = CkJsonObjectW_stringOf(json,L"nameservers[i].objectClassName"); ldhName = CkJsonObjectW_stringOf(json,L"nameservers[i].ldhName"); i = i + 1; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"rdapConformance"); while (i < count_i) { CkJsonObjectW_putI(json,i); strVal = CkJsonObjectW_stringOf(json,L"rdapConformance[i]"); i = i + 1; } i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"notices"); while (i < count_i) { CkJsonObjectW_putI(json,i); title = CkJsonObjectW_stringOf(json,L"notices[i].title"); j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"notices[i].description"); while (j < count_j) { CkJsonObjectW_putJ(json,j); strVal = CkJsonObjectW_stringOf(json,L"notices[i].description[j]"); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"notices[i].links"); while (j < count_j) { CkJsonObjectW_putJ(json,j); href = CkJsonObjectW_stringOf(json,L"notices[i].links[j].href"); v_type = CkJsonObjectW_stringOf(json,L"notices[i].links[j].type"); j = j + 1; } i = i + 1; } CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponse); CkJsonObjectW_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.