PHP code example of knotsphp / flushdns

1. Go to this page and download the library: Download knotsphp/flushdns 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/ */

    

knotsphp / flushdns example snippets


use KnotsPHP\FlushDNS\FlushDNS;

// Flush DNS cache
$success = FlushDNS::run(); 

// Only get the command
$command = FlushDNS::getCommand();

// Check if the command needs elevated privileges
$needsElevation = FlushDNS::needsElevation();

// Get options to ignore dns cache
$flushDnsOptions = FlushDNS::getCurlOpts();

// Make the request
$curl = curl_init();
curl_setopt_array($curl, array_merge(
    [
        CURLOPT_URL => "https://app.unolia.com/api/v1/domains",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            "Accept: application/json",
            "Authorization: Bearer 123"
        ],
    ],
    $flushDnsOptions,
));
$response = curl_exec($curl);
$domains = json_decode($response);
curl_close($curl);