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
(PowerBuilder) 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.
integer li_rc oleobject loo_Http string ls_Url string ls_JsonResp oleobject loo_Json integer li_Status integer li_TC integer li_RD integer li_RA integer li_AD integer li_CD integer i integer li_Count_i string ls_Name integer li_Type integer li_TTL string ls_Data string ls_IpAddr // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Send the following CURL request: curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A' loo_Http.Accept = "application/dns-json" ls_Url = "https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A" ls_JsonResp = loo_Http.QuickGetStr(ls_Url) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http return end if Write-Debug "Response Status Code: " + string(loo_Http.LastStatus) loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.Load(ls_JsonResp) loo_Json.EmitCompact = 0 Write-Debug loo_Json.Emit() if loo_Http.LastStatus <> 200 then Write-Debug "Failed." destroy loo_Http destroy loo_Json return end if // 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 li_Status = loo_Json.IntOf("Status") li_TC = loo_Json.BoolOf("TC") li_RD = loo_Json.BoolOf("RD") li_RA = loo_Json.BoolOf("RA") li_AD = loo_Json.BoolOf("AD") li_CD = loo_Json.BoolOf("CD") i = 0 li_Count_i = loo_Json.SizeOfArray("Question") do while i < li_Count_i loo_Json.I = i ls_Name = loo_Json.StringOf("Question[i].name") li_Type = loo_Json.IntOf("Question[i].type") i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("Answer") // The domain name resolves to 1 or more IP addresses.. do while i < li_Count_i loo_Json.I = i ls_Name = loo_Json.StringOf("Answer[i].name") li_Type = loo_Json.IntOf("Answer[i].type") li_TTL = loo_Json.IntOf("Answer[i].TTL") ls_IpAddr = loo_Json.StringOf("Answer[i].data") Write-Debug "IP Address: " + ls_IpAddr i = i + 1 loop destroy loo_Http destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.