Chilkat Examples

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

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
MedTunnel

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) 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

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    String sUrl
    String sJsonResp
    Handle hoJson
    Integer iStatus
    Boolean iTC
    Boolean iRD
    Boolean iRA
    Boolean iAD
    Boolean iCD
    Integer i
    Integer iCount_i
    String sName
    Integer iType
    Integer iTTL
    String sData
    String sIpAddr
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Send the following CURL request:   curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A'

    Set ComAccept Of hoHttp To "application/dns-json"

    Move "https://cloudflare-dns.com/dns-query?name=chilkat.io&type=A" To sUrl

    Get ComQuickGetStr Of hoHttp sUrl To sJsonResp
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComLastStatus Of hoHttp To iTemp1
    Showln "Response Status Code: " iTemp1

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoad Of hoJson sJsonResp To iSuccess
    Set ComEmitCompact Of hoJson To False
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iTemp1
    If (iTemp1 <> 200) Begin
        Showln "Failed."
        Procedure_Return
    End

    // 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

    Get ComIntOf Of hoJson "Status" To iStatus
    Get ComBoolOf Of hoJson "TC" To iTC
    Get ComBoolOf Of hoJson "RD" To iRD
    Get ComBoolOf Of hoJson "RA" To iRA
    Get ComBoolOf Of hoJson "AD" To iAD
    Get ComBoolOf Of hoJson "CD" To iCD
    Move 0 To i
    Get ComSizeOfArray Of hoJson "Question" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "Question[i].name" To sName
        Get ComIntOf Of hoJson "Question[i].type" To iType
        Move i + 1 To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "Answer" To iCount_i
    // The domain name resolves to 1 or more IP addresses..
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "Answer[i].name" To sName
        Get ComIntOf Of hoJson "Answer[i].type" To iType
        Get ComIntOf Of hoJson "Answer[i].TTL" To iTTL
        Get ComStringOf Of hoJson "Answer[i].data" To sIpAddr

        Showln "IP Address: " sIpAddr
        Move i + 1 To i
    Loop



End_Procedure

 

© 2000-2022 Chilkat Software, Inc. All Rights Reserved.