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 Translate
Activix CRM
Adyen
Amazon DynamoDB
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
Lightspeed

MYOB
Magento
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WiX
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(DataFlex) AbuseIPDB Check Endpoint

The check endpoint accepts a single IP address (v4 or v6). Optionally you may set the maxAgeInDays parameter to only return reports within the last x amount of days.

For more information, see https://docs.abuseipdb.com/?shell#check-endpoint

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoReq
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sReportedAt
    String sComment
    Integer iReporterId
    String sReporterCountryCode
    String sReporterCountryName
    Integer j
    Integer iCount_j
    Integer iIntVal
    String sDataIpAddress
    Boolean iDataIsPublic
    Integer iDataIpVersion
    Boolean iDataIsWhitelisted
    Integer iDataAbuseConfidenceScore
    String sDataCountryCode
    String sDataCountryName
    String sDataUsageType
    String sDataIsp
    String sDataDomain
    Integer iDataTotalReports
    Integer iDataNumDistinctUsers
    String sDataLastReportedAt
    Integer i
    Integer iCount_i
    String sTemp1

    // This example assumes 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

    // Implements the following CURL command:

    // curl -G https://api.abuseipdb.com/api/v2/check \
    //   --data-urlencode "ipAddress=118.25.6.39" \
    //   -d maxAgeInDays=90 \
    //   -d verbose \
    //   -H "Key: $YOUR_API_KEY" \
    //   -H "Accept: application/json"

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "GET"
    Set ComPath Of hoReq To "/api/v2/check"
    Set ComContentType Of hoReq To "application/x-www-form-urlencoded"
    Send ComAddParam To hoReq "maxAgeInDays" "90"
    Send ComAddParam To hoReq "verbose" ""
    Send ComAddParam To hoReq "ipAddress" "118.25.6.39"

    Send ComAddHeader To hoReq "Key" "$YOUR_API_KEY"
    Send ComAddHeader To hoReq "Accept" "application/json"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://api.abuseipdb.com/api/v2/check" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "data": {
    //     "ipAddress": "118.25.6.39",
    //     "isPublic": true,
    //     "ipVersion": 4,
    //     "isWhitelisted": false,
    //     "abuseConfidenceScore": 100,
    //     "countryCode": "CN",
    //     "countryName": "China",
    //     "usageType": "Data Center/Web Hosting/Transit",
    //     "isp": "Tencent Cloud Computing (Beijing) Co. Ltd",
    //     "domain": "tencent.com",
    //     "hostnames": [
    //     ],
    //     "totalReports": 1,
    //     "numDistinctUsers": 1,
    //     "lastReportedAt": "2018-12-20T20:55:14+00:00",
    //     "reports": [
    //       {
    //         "reportedAt": "2018-12-20T20:55:14+00:00",
    //         "comment": "Dec 20 20:55:14 srv206 sshd[13937]: Invalid user oracle from 118.25.6.39",
    //         "categories": [
    //           18,
    //           22
    //         ],
    //         "reporterId": 1,
    //         "reporterCountryCode": "US",
    //         "reporterCountryName": "United States"
    //       }
    //     ]
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    Get ComStringOf Of hoJResp "data.ipAddress" To sDataIpAddress
    Get ComBoolOf Of hoJResp "data.isPublic" To iDataIsPublic
    Get ComIntOf Of hoJResp "data.ipVersion" To iDataIpVersion
    Get ComBoolOf Of hoJResp "data.isWhitelisted" To iDataIsWhitelisted
    Get ComIntOf Of hoJResp "data.abuseConfidenceScore" To iDataAbuseConfidenceScore
    Get ComStringOf Of hoJResp "data.countryCode" To sDataCountryCode
    Get ComStringOf Of hoJResp "data.countryName" To sDataCountryName
    Get ComStringOf Of hoJResp "data.usageType" To sDataUsageType
    Get ComStringOf Of hoJResp "data.isp" To sDataIsp
    Get ComStringOf Of hoJResp "data.domain" To sDataDomain
    Get ComIntOf Of hoJResp "data.totalReports" To iDataTotalReports
    Get ComIntOf Of hoJResp "data.numDistinctUsers" To iDataNumDistinctUsers
    Get ComStringOf Of hoJResp "data.lastReportedAt" To sDataLastReportedAt
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "data.hostnames" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "data.reports" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "data.reports[i].reportedAt" To sReportedAt
        Get ComStringOf Of hoJResp "data.reports[i].comment" To sComment
        Get ComIntOf Of hoJResp "data.reports[i].reporterId" To iReporterId
        Get ComStringOf Of hoJResp "data.reports[i].reporterCountryCode" To sReporterCountryCode
        Get ComStringOf Of hoJResp "data.reports[i].reporterCountryName" To sReporterCountryName
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "data.reports[i].categories" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComIntOf Of hoJResp "data.reports[i].categories[j]" To iIntVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

 

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