Description
Use the IP Block API's to Block and Unblock IP's and list Blocked IP's
Block IP
Parameters
Sample Code
curl --insecure -d "dip=IP range" -X POST "https://hostname:2005/index.php?api=json&act=ipblock&add_ip=1&apiuser=user_name&apikey=pass_api_key"
<?php
$url = 'https://hostname:2005/index.php?api=json&act=ipblock&apiuser=user_name&apikey=pass_api_key';
$post = array('add_ip' => 1,
'dip' => 'IP_range',
);
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method.
$res = json_decode($resp, true);
// Done ?
if(!empty($res['done'])){
echo "<pre>";
print_r($res['done']['msg']);
echo "</pre>";
}else{
print_r($res['error']);
}
Output
IP Address Successfully blocked
Unblock IP
Parameters
Sample Code
curl --insecure "https://hostname:2005/index.php?api=json&act=ipblock&delete=ip_index_number&apiuser=user_name&apikey=pass_api_key"
<?php
$url = 'https://hostname:2005/index.php?api=json&act=ipblock&delete=ip_index_number&apiuser=user_name&apikey=pass_api_key';
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method.
$res = json_decode($resp, true);
// Done ?
if(!empty($res['done'])){
echo "<pre>";
print_r($res['done']['msg']);
echo "</pre>";
}else{
print_r($res['error']);
}
Output
IP Unblocked Successfully
List Blocked IP
Parameters
Use this API to list IP Block in Webuzo account.
Sample Code
curl --insecure -u "USERNAME:PASSWORD" -X POST "https://hostip:2003/index.php?api=json&act=ipblock"
<?php
$url = 'https://hostname:2005/index.php?api=json&act=ipblock&apiuser=user_name&apikey=pass_api_key';
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);
// Done ?
if(!empty($res['add_list'])){
echo "<pre>";
print_r($res['add_list']);
echo "</pre>";
}
Output
Array
(
[0] => 1.0.0.0/32
[1] => 1.0.0.1/32
)