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
(Visual FoxPro) 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.
LOCAL loHttp LOCAL lcUrl LOCAL lcJsonResp LOCAL loJson LOCAL lnStatus LOCAL lnTC LOCAL lnRD LOCAL lnRA LOCAL lnAD LOCAL lnCD LOCAL i LOCAL lnCount_i LOCAL lcName LOCAL lnType LOCAL lnTTL LOCAL lcData LOCAL lcIpAddr * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * 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 <> 1) THEN ? loHttp.LastErrorText RELEASE loHttp CANCEL ENDIF ? "Response Status Code: " + STR(loHttp.LastStatus) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.Load(lcJsonResp) loJson.EmitCompact = 0 ? loJson.Emit() IF (loHttp.LastStatus <> 200) THEN ? "Failed." RELEASE loHttp RELEASE loJson CANCEL 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") lnTC = loJson.BoolOf("TC") lnRD = loJson.BoolOf("RD") lnRA = loJson.BoolOf("RA") lnAD = loJson.BoolOf("AD") lnCD = 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.