Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(Visual FoxPro) Cloudfare DNS over HTTPS

Cloudflare 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.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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.

loHttp = CreateObject('Chilkat_9_5_0.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)

loJson = CreateObject('Chilkat_9_5_0.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-2019 Chilkat Software, Inc. All Rights Reserved.