Skip to content
fkmhrk edited this page Sep 24, 2013 · 3 revisions

TopicAPI

Get TopicAPI instance

require_once ('<library_root>'. '/src/kii/KiiAppAPI.php');

$context = new KiiContext(APP_ID, APP_KEY, SITE);
$appPpi = new KiiAppAPI($context);
$api = $appApi->topicAPI();

Create Topic

$userId = 'user1234';
$topicName = 'test';
$topic = new KiiTopic(new KiiUser($userId), $topicName);

try {
	$topicApi->create($topic);
} catch (CloudException $e) {
	//error handling
}

Send Push Message

$topicName = 'test';
$topic = new KiiTopic($group, $topicName);
$message = new KiiTopicMessage();
$message->data['msg'] = 'hello';

try {
	$topicApi->sendMessage($topic, $message);
} catch (CloudException $e) {
	//error handling
}
Clone this wiki locally