-
-
Save mosladil/0d69229c737284c39169 to your computer and use it in GitHub Desktop.
Kerio Workspace - Sample Search Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Kerio Workspace - Sample Search Application. | |
* | |
* @copyright Copyright © 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