SpamWall Operations Manual

SpamWall API - Example Script

The SpamWall Spam Firewall API is web service based and should be "called" like any other URL with the initiating application or script appending the appropriate command and variables to the URL in standard HTTP GET and POST request format and the output/response would be received in XML format.

For more info on the SpamWall API, see the SpamWall API Operating Guide.

API Example Script (add user account)

 
<?php
 
// Authentication details
$login = array(
'username' => 'admin',
'password' => 'your-password',
);
 
// Command and parameters
$command = array(
  'command' => 'add_user',
  'username'   => 'testuser',
  'password'   => 'test-pass',
  'email'   => 'test@domain.com', 
  'full_name'   => 'Test User Account',
);
 
$get = '';
$post = '';
 
foreach ($login as $key => $value) { $post .= $key .'='.urlencode($value) . '&'; }
$post = rtrim($post, '&');
 
foreach($command as $key => $value) { $get .= $key.'='.urlencode($value).'&'; }
$get = rtrim($get, '&');
 
$ch = curl_init('http://spamwall.yourdomain.com/api/api.php?' . $get);
 
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_USERPWD, 'admin:your-pass');
 
$response = curl_exec($ch);
curl_close ($ch);
 
echo $response;
        

Example Commands:


 
Add domain:
'command' => 'add_domain', 'name' => 'testdomain.com', 'ip' => '192.168.173.25', 'port' => '25',
Change domain:
'command' => 'change_domain',
'name' => 'testdomain.com',
'ip' => '192.168.173.100',
'port' => '25',
Delete domain:
'command' => 'delete_domain',
'name' => 'testdomain.com',
List users:
'command' => 'list_users',
'users' => 'all',
Add user:
'command' => 'add_user',
'username' => 'testuser',
'password' => 'test-pass',
'email' => 'test@domain.com',
'full_name' => 'Test User Account',
Change user:
'command' => 'change_user',
'user' => 'testuser',
'username' => 'testuser',
'email' => 'test2@domain.com',
'full_name' => 'Test2 User Account',
Change user password:
'command' => 'change_user_password',
'user' => 'testuser',
'newpass' => 'test-pass2'
Delete user:
'command' => 'delete_user',
'user' => 'testuser',
Whitelist/blacklist add and delete:
'command' => 'whitelist_add',
'email' => 'name@domain.com',
'command' => 'whitelist_del',
'email' => 'name@domain.com',
'command' => 'blacklist_add',
'email' => 'name@domain.com',
'command' => 'blacklist_del',
'email' => 'name@domain.com',

 

If you require advice or assistance with the SpamWall API you can request support from service@spamwall.com or complete and submit our online contact form.