REST API for developers

January 05, 2012 • Administrator       
Synopsis

The CensorNet Hosted Web Security platform provides a web services REST API for developers to integrate the service into their own applications.

Article
This article is out of date. Please check the new Documentation Portal for Hybrid Web Security.

The CensorNet Hosted Web Security platform provides a web services REST API for developers to integrate the service into their own applications. It can also be used to create maintenance programs, such as being able to automatically import users into your account from an external source (e.g. LDAP, RADIUS, PostgreSQL, MySQL, etc) or export reporting data for processing elsewhere. As the API is RESTful, it supports the standard HTTP methods of GET, POST, PUT and DELETE. All message payloads use JSON format for lightweight communication. As it is based on HTTP, the API can be used from any programming language that provides access to the HTTP protocol (e.g. Perl, PHP, C#, C, etc).

Any feature or option that you see in the Cloudwebfiltering.com web dashboard can be accessed via the API. That's powerful!

 

Example uses of the API

 

  • Create your own web filtering applications on your platform of choice
  • Integrate the service into your own application / portal
  • Develop your own Graphical User Interface for our Hosted Web Security service
  • Automatic provisioning of customer and user accounts
  • Export users from an external data source and import into your Hosted Web Security account
  • Synchronise custom URL lists with internal / external applications (e.g. Intranet)
  • ....plus much more

 

Example usage

The following simplified example is given in PHP but the same principal applies to other programming languages. It shows how to retrieve a list of users and groups from the API.

 

   

// Create an object to store fields in
$cncauth = new stdClass;
$cncauth->user = "admin@domain.com";
$cncauth->timestamp = time();
$cncauth->nonce = "";
$cncauth->body =""; // GET request so this is empty
$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i = 0; $i < 20; $i++) {
  $cncauth->nonce .= $characters[mt_rand(0, strlen($characters))];
}
// Create a signature to send with our request
$cncauth->signature = hash_hmac('sha256', 'GET' . "http://www.cloudwebfiltering.com/customers/api/users_groups_tree" . hash('sha256', $cncauth->body) . $cncauth->timestamp . $cncauth->nonce, $secret_key);
$cncauth_json = json_encode($cncauth);

 

To access the REST API you will need to obtain the REST API developer documentation from your account manager which is available to all customers at no extra cost.

Related articles


Last modified on Fri, October 26, 2012 « Back