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
(DataFlex) Cloudfare DNS over HTTPSCloudflare offers a DNS over HTTPS resolver at: https://cloudflare-dns.com/dns-query This example demonstrates how to do a DNS lookup for a domain using Cloudfare's HTTPS resolver.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp String sUrl String sJsonResp Handle hoJson Boolean iSuccess Integer iStatus Boolean iTC Boolean iRD Boolean iRA Boolean iAD Boolean iCD Integer i Integer iCount_i String sName Integer iType Integer iTTL String sData String sIpAddr String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Send the following CURL request: curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A' Set ComAccept Of hoHttp To "application/dns-json" Move "https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A" To sUrl Get ComQuickGetStr Of hoHttp sUrl To sJsonResp Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComLastStatus Of hoHttp To iTemp1 Showln "Response Status Code: " iTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoad Of hoJson sJsonResp To iSuccess Set ComEmitCompact Of hoJson To False Get ComEmit Of hoJson To sTemp1 Showln sTemp1 Get ComLastStatus Of hoHttp To iTemp1 If (iTemp1 <> 200) Begin Showln "Failed." Procedure_Return End // Sample output... // (See the parsing code below..) // // { // "Status": 0, // "TC": false, // "RD": true, // "RA": true, // "AD": false, // "CD": false, // "Question": [ // { // "name": "chilkat.io.", // "type": 1 // } // ], // "Answer": [ // { // "name": "chilkat.io.", // "type": 1, // "TTL": 900, // "data": "52.25.83.238" // } // ] // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get ComIntOf Of hoJson "Status" To iStatus Get ComBoolOf Of hoJson "TC" To iTC Get ComBoolOf Of hoJson "RD" To iRD Get ComBoolOf Of hoJson "RA" To iRA Get ComBoolOf Of hoJson "AD" To iAD Get ComBoolOf Of hoJson "CD" To iCD Move 0 To i Get ComSizeOfArray Of hoJson "Question" To iCount_i While (i < iCount_i) Set ComI Of hoJson To i Get ComStringOf Of hoJson "Question[i].name" To sName Get ComIntOf Of hoJson "Question[i].type" To iType Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJson "Answer" To iCount_i // The domain name resolves to 1 or more IP addresses.. While (i < iCount_i) Set ComI Of hoJson To i Get ComStringOf Of hoJson "Answer[i].name" To sName Get ComIntOf Of hoJson "Answer[i].type" To iType Get ComIntOf Of hoJson "Answer[i].TTL" To iTTL Get ComStringOf Of hoJson "Answer[i].data" To sIpAddr Showln "IP Address: " sIpAddr Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.