PHP code example of clash82 / cachedhttpbl

1. Go to this page and download the library: Download clash82/cachedhttpbl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

clash82 / cachedhttpbl example snippets




// define the suspicious IP address (fill this with the IP address you want to check)
$ip = '';

// provide a valid http:BL API key (you can create one at the http:BL dashboard)
// note: there is no way to validate this key programmatically, so ensure it's correct
$httpblApiKey = '';

// use namespace autoloader
hedHttpBl = new CachedHttpBL\Client($provider, $adapter);

try {
    // fetch response data from the http:BL service
    $response = $cachedHttpBl->checkIP($ip);

    // use a translator to provide more detailed information about the response (optional but useful)
    $translator = new CachedHttpBL\Translator\ProjectHoneyPotTranslator();
    $translator->translate($response);

    // output formatted details about the IP address
    printf("The http:BL service was requested to get details about %s IP address:\n\n", $ip);

    printf("Type code: %d\n", $response->getType());
    printf("Activity code: %d (%s)\n", $response->getActivity(), $translator->getActivityDescription());
    printf("Threat code: %d (%s)\n", $response->getThreat(), $translator->getThreatDescription());
    printf("Type meaning code: %d (%s)\n", $response->getTypeMeaning(), $translator->getTypeMeaningDescription());

    // save the cache for future use
    $adapter->writeCache();
} catch (\Exception $e) {
    // handle errors gracefully
    printf("Error: Unable to retrieve details for the given IP address. %s\n", $e->getMessage());
}