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
(Lianja) 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.
// This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loHttp = createobject("CkHttp") // Send the following CURL request: curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A' loHttp.Accept = "application/dns-json" lcUrl = "https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A" lcJsonResp = loHttp.QuickGetStr(lcUrl) if (loHttp.LastMethodSuccess <> .T.) then ? loHttp.LastErrorText release loHttp return endif ? "Response Status Code: " + str(loHttp.LastStatus) loJson = createobject("CkJsonObject") loJson.Load(lcJsonResp) loJson.EmitCompact = .F. ? loJson.Emit() if (loHttp.LastStatus <> 200) then ? "Failed." release loHttp release loJson return endif // 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 lnStatus = loJson.IntOf("Status") llTC = loJson.BoolOf("TC") llRD = loJson.BoolOf("RD") llRA = loJson.BoolOf("RA") llAD = loJson.BoolOf("AD") llCD = loJson.BoolOf("CD") i = 0 lnCount_i = loJson.SizeOfArray("Question") do while i < lnCount_i loJson.I = i lcName = loJson.StringOf("Question[i].name") lnType = loJson.IntOf("Question[i].type") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("Answer") // The domain name resolves to 1 or more IP addresses.. do while i < lnCount_i loJson.I = i lcName = loJson.StringOf("Answer[i].name") lnType = loJson.IntOf("Answer[i].type") lnTTL = loJson.IntOf("Answer[i].TTL") lcIpAddr = loJson.StringOf("Answer[i].data") ? "IP Address: " + lcIpAddr i = i + 1 enddo release loHttp release loJson |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.