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
(AutoIt) 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. $oHttp = ObjCreate("Chilkat.Http") ; Send the following CURL request: curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A' $oHttp.Accept = "application/dns-json" Local $sUrl = "https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A" Local $sJsonResp = $oHttp.QuickGetStr($sUrl) If ($oHttp.LastMethodSuccess <> True) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf ConsoleWrite("Response Status Code: " & $oHttp.LastStatus & @CRLF) $oJson = ObjCreate("Chilkat.JsonObject") $oJson.Load($sJsonResp) $oJson.EmitCompact = False ConsoleWrite($oJson.Emit() & @CRLF) If ($oHttp.LastStatus <> 200) Then ConsoleWrite("Failed." & @CRLF) Exit 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 Local $iStatus Local $bTC Local $bRD Local $bRA Local $bAD Local $bCD Local $i Local $iCount_i Local $sName Local $iType Local $iTTL Local $sData Local $sIpAddr $iStatus = $oJson.IntOf("Status") $bTC = $oJson.BoolOf("TC") $bRD = $oJson.BoolOf("RD") $bRA = $oJson.BoolOf("RA") $bAD = $oJson.BoolOf("AD") $bCD = $oJson.BoolOf("CD") $i = 0 $iCount_i = $oJson.SizeOfArray("Question") While $i < $iCount_i $oJson.I = $i $sName = $oJson.StringOf("Question[i].name") $iType = $oJson.IntOf("Question[i].type") $i = $i + 1 Wend $i = 0 $iCount_i = $oJson.SizeOfArray("Answer") ; The domain name resolves to 1 or more IP addresses.. While $i < $iCount_i $oJson.I = $i $sName = $oJson.StringOf("Answer[i].name") $iType = $oJson.IntOf("Answer[i].type") $iTTL = $oJson.IntOf("Answer[i].TTL") $sIpAddr = $oJson.StringOf("Answer[i].data") ConsoleWrite("IP Address: " & $sIpAddr & @CRLF) $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.