Web-API

From Cerberus Helpdesk Wiki

Jump to: navigation, search

Contents

[edit] Cerb4 RESTful Web API - Introduction

To begin using the web API, you will first need to enable the plugin. Go to Helpdesk Setup -> Plugins, select the checkbox next to "Cerberus Helpdesk: Web Services API", and Save Changes.

You will now have a new Web API tab in Helpdesk Setup. Click on that tab, and enter a Nickname for your new access key (you can have many different keys, each with different permissions). Click Save Changes, update the Rights and Restricted IPs, and click Save Changes to save those updates. You'll note that there's an Access Key and a Secret Key there; you'll need those for the next step.

Now we're almost ready to start using the API. Copy http://www.cerberusweb.com/downloads/Cerb4WebApi.php.txt to the directory in your webpath where you'll be working, and change the extension to .php. We'll start with a really simple example. In that same directory, create index.php as follows:

<?php
require_once("Cerb4WebApi.php");

$access_key = "";
$secret_key = "";

$cerb4 = new Cerb4_WebApi($access_key, $secret_key);

$url = 'http://localhost/cerb4/index.php/webapi/addresses/list.xml';
$out = $cerb4->get($url);

if(null != ($content_type = $cerb4->getContentType()))
    header("Content-Type: " . $content_type);
echo $out;
?>

When you load that index.php file, you should get a list of the addresses in your system (if you have at least Read permission on the Address Book (People) category). Let's try a more complicated example, changing a phone number of an address (just the inner part of the code needs changed):

<?php
...

$url = 'http://localhost/cerb4/index.php/webapi/addresses/42.xml';
$payload = '<address><phone>(714) 671-9090</phone></address>';
$out = $cerb4->put($url, $payload);

...
?>

The web api supports get, put, post, and delete methods on most of the Objects. Please see each individual object page for more details about methods available.

[edit] Notes and Caveats

http://www.cerberusweb.com/downloads/Cerb4WebApi.php.txt is written for php5. For PHP4, use http://www.cerberusweb.com/downloads/Cerb4WebApi_php4.php.txt Also, it is not necessary to use PHP on the client side, that is simply the example provided.

With regard to the $url arguments above, http://localhost/cerb4/index.php needs to match the url format of your helpdesk. If your desk is located at http://localhost/admin, then use that instead. Also, url rewriting removes the need for the "index.php/" portion of the url, so it may look like http://demo.cerb4.com/admin/webapi/addresses/42.xml

[edit] REST (Web-API) Support Center Example

The REST SC is an example Support Center created entirely through the Web API. It is, essentially, infinitely customizable, with a solid core of the desired functionality to use as examples.

REST Support Center (Web-API)

[edit] API Class Links

[edit] Addresses

Addresses (Web-API)

[edit] Organizations

Organizations (Web-API)

[edit] Tickets

Tickets (Web-API)

[edit] Messages

Messages (Web-API)

[edit] Message Notes

Message Notes (Web-API)

[edit] Comments

Comments (Web-API)

[edit] Tasks

Tasks (Web-API)

[edit] Knowledgebase Articles

KB Articles (Web-API)

[edit] Parser

Parser (Web-API)

[edit] Fetch & Retrieve

Fetch & Retrieve (Web-API)

Personal tools