Skip to content

Instantly share code, notes, and snippets.

@mosladil
Created January 11, 2013 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosladil/0d69229c737284c39169 to your computer and use it in GitHub Desktop.
Save mosladil/0d69229c737284c39169 to your computer and use it in GitHub Desktop.
Kerio Workspace - Sample Search Application
<?php
/**
* Kerio Workspace - Sample Search Application.
*
* @copyright Copyright &copy; 2012-2012 Kerio Technologies s.r.o.
* @version 1.3.0.1
*/
require_once(dirname(__FILE__) . '/src/KerioWorkspaceApi.php');
/* Set your Kerio Workspace account */
$hostname = '';
$username = '';
$password = '';
$api = new KerioWorkspaceApi('Sample application', 'Kerio Technologies s.r.o.', '1.3.0.1');
/* Main application */
try {
/* Login */
$api->setComponentClient();
$session = $api->login($hostname, $username, $password);
/* Search */
$params = array('query' => 'What am I looking for?');
$result = $api->sendRequest('Search', $params);
/* Parse response */
if (count($result['items']) > 0) {
print '<ul>';
foreach ($result['items'] as $item) {
$description = (isset($item['highlightedText'][0])) ? $item['highlightedText'][0] : '';
printf('<li><a href="https://%s/#page-%d">%s</a> <i>%s</i><br>%s</li>', $hostname, $item['id'], $item['name'], $item['type'], $description);
}
print '</ul>';
}
else {
print 'Your search did not match any documents.';
}
}
catch (KerioApiException $error) {
/* Catch possible errors */
print $error->getMessage();
}
/* Logout */
if (isset($session)) $api->logout();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment