Lianja
Lianja
Cloudfare DNS over HTTPS
See more Cloudfare Examples
Cloudflare offers a DNS over HTTPS resolver at: https://cloudflare-dns.com/dns-queryThis example demonstrates how to do a DNS lookup for a domain using Cloudfare's HTTPS resolver.
Chilkat Lianja Downloads
// 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