Using the activeCollab API wrapper in your code should be done in three steps:
<?php
// Include activeCollab API wrapper
require_once '/lib/include.php';
// Authenticate
ActiveCollab::setAPIUrl('http://localhost/corporate/public/api.php');
ActiveCollab::setKey('4-EUASVXm3VgJXhUfIsN1uGRASO1i0gIiLrIsbuF5e');
// List projects
print '<pre>';
$projects = ActiveCollab::listProjects();
if($projects) {
foreach($projects as $project) {
print 'Project #' . $project->getId() . ': ' . htmlspecialchars($project->getName()) . '<br />';
} // foreach
} // if
print '</pre>';
?>
To find your token key and API URL, go to API Settings page of your user profile:
After meeting those requirements you can create objects and call methods in order to read and manipulate activeCollab data.
Some of these methods can throw an exception if they receive invalid parameters. In the following example, we'll use a try/catch block to handle any error that may happen (group with ID 1 does not exist; authentication problems; insufficient permissions etc):
try {
$group = ActiveCollab::findProjectGroupById(1);
} catch (Exception $e) {
echo $e->getMessage();
echo $e->getFile();
echo $e->getLine();
}