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
(PureBasic) AbuseIPDB Check EndpointThe 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
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkJsonObject.pb" IncludeFile "CkHttpRequest.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; 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 req.i = CkHttpRequest::ckCreate() If req.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpRequest::setCkHttpVerb(req, "GET") CkHttpRequest::setCkPath(req, "/api/v2/check") CkHttpRequest::setCkContentType(req, "application/x-www-form-urlencoded") CkHttpRequest::ckAddParam(req,"maxAgeInDays","90") CkHttpRequest::ckAddParam(req,"verbose","") CkHttpRequest::ckAddParam(req,"ipAddress","118.25.6.39") CkHttpRequest::ckAddHeader(req,"Key","$YOUR_API_KEY") CkHttpRequest::ckAddHeader(req,"Accept","application/json") resp.i = CkHttp::ckSynchronousRequest(http,"api.abuseipdb.com",443,1,req) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkHttpRequest::ckDispose(req) ProcedureReturn EndIf jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(jResp,CkHttpResponse::ckBodyStr(resp)) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttpResponse::ckStatusCode(resp) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttpResponse::ckHeader(resp) Debug "Failed." CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkHttpRequest::ckDispose(req) CkJsonObject::ckDispose(jResp) ProcedureReturn EndIf CkHttpResponse::ckDispose(resp) ; 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": 1, ; "countryCode": "CN", ; "usageType": "Data Center\/Web Hosting\/Transit", ; "isp": "Tencent Cloud Computing (Beijing) Co. Ltd", ; "domain": "tencent.com", ; "hostnames": [ ; ], ; "countryName": "China", ; "totalReports": 2, ; "numDistinctUsers": 1, ; "lastReportedAt": "2021-04-03T18:55:00+00:00", ; "reports": [ ; { ; "reportedAt": "2021-03-10T10:07:53+00:00", ; "comment": "SSH login attempts with user root.", ; "categories": [ ; 18, ; 22 ; ], ; "reporterId": 54484, ; "reporterCountryCode": "CN", ; "reporterCountryName": "China" ; }, ; { ; "reportedAt": "2021-03-09T09:47:57+00:00", ; "comment": "SSH login attempts with user root.", ; "categories": [ ; 18, ; 22 ; ], ; "reporterId": 54484, ; "reporterCountryCode": "CN", ; "reporterCountryName": "China" ; } ; ] ; } ; } ; Sample code for parsing the JSON response... ; Use the following online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON reportedAt.s comment.s reporterId.i reporterCountryCode.s reporterCountryName.s j.i count_j.i intVal.i dataIpAddress.s = CkJsonObject::ckStringOf(jResp,"data.ipAddress") dataIsPublic.i = CkJsonObject::ckBoolOf(jResp,"data.isPublic") dataIpVersion.i = CkJsonObject::ckIntOf(jResp,"data.ipVersion") dataIsWhitelisted.i = CkJsonObject::ckBoolOf(jResp,"data.isWhitelisted") dataAbuseConfidenceScore.i = CkJsonObject::ckIntOf(jResp,"data.abuseConfidenceScore") dataCountryCode.s = CkJsonObject::ckStringOf(jResp,"data.countryCode") dataUsageType.s = CkJsonObject::ckStringOf(jResp,"data.usageType") dataIsp.s = CkJsonObject::ckStringOf(jResp,"data.isp") dataDomain.s = CkJsonObject::ckStringOf(jResp,"data.domain") dataCountryName.s = CkJsonObject::ckStringOf(jResp,"data.countryName") dataTotalReports.i = CkJsonObject::ckIntOf(jResp,"data.totalReports") dataNumDistinctUsers.i = CkJsonObject::ckIntOf(jResp,"data.numDistinctUsers") dataLastReportedAt.s = CkJsonObject::ckStringOf(jResp,"data.lastReportedAt") i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"data.hostnames") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"data.reports") While i < count_i CkJsonObject::setCkI(jResp, i) reportedAt = CkJsonObject::ckStringOf(jResp,"data.reports[i].reportedAt") comment = CkJsonObject::ckStringOf(jResp,"data.reports[i].comment") reporterId = CkJsonObject::ckIntOf(jResp,"data.reports[i].reporterId") reporterCountryCode = CkJsonObject::ckStringOf(jResp,"data.reports[i].reporterCountryCode") reporterCountryName = CkJsonObject::ckStringOf(jResp,"data.reports[i].reporterCountryName") j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"data.reports[i].categories") While j < count_j CkJsonObject::setCkJ(jResp, j) intVal = CkJsonObject::ckIntOf(jResp,"data.reports[i].categories[j]") j = j + 1 Wend i = i + 1 Wend CkHttp::ckDispose(http) CkHttpRequest::ckDispose(req) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.