-
Notifications
You must be signed in to change notification settings - Fork 2
Use cases
fkmhrk edited this page Sep 18, 2013
·
4 revisions
Access token will be given.
require_once (dirname(__FILE__). '/libs/kiilib/src/kii/KiiAppAPI.php');
$context = new KiiContext(APP_ID, APP_KEY, SITE);
$context->setAccessToken($accessToken);
$appApi = new KiiAppAPI($context);
$userApi = $appApi->userAPI();
try {
$user = $userApi->getUser(new KiiUser('me'));
} catch (CloudException $e) {
//error handling
}
EmailAddress will be given.
require_once (dirname(__FILE__). '/libs/kiilib/src/kii/KiiAppAPI.php');
$context = new KiiContext(APP_ID, APP_KEY, SITE);
$api = new KiiAppAPI($context);
$userApi = $api->userAPI();
$topicApi = $appApi->topicAPI();
# login as App Admin
try {
$api->loginAsAdmin($clientId, $clientSecret);
} catch (CloudException $e) {
// error handling
return;
}
# find user
$user = null;
try {
$user = $userApi->findByEmail($emailAddress);
} catch (CloudException $e) {
// error handling
return;
}
# send Topic message
$topicName = 'inbox';
$topic = new KiiTopic($user, $topicName);
$message = new KiiTopicMessage();
$message->data['msg'] = 'hello';
try {
$topicApi->sendMessage($topic, $message);
} catch (CloudException $e) {
//error handling
}