Sample Code

The following demonstrates how to connect to the WHASOLS API from a PHP script using CURL.


<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://whasols.com/rapi/AddBannedIp',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>[
"token"=>"API token Here",
"ip_address"=>"IP address to be whitelist here",
"reason"=>"",
"days"=>"days here",
"expires"=>"",
],
));
$response = curl_exec($curl);
curl_close($curl);

// Decode response $jsonData = json_decode($response, true);
// Dump array structure for inspection var_dump($jsonData);
?>