本文整理汇总了PHP中Chat::getNewMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::getNewMessages方法的具体用法?PHP Chat::getNewMessages怎么用?PHP Chat::getNewMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::getNewMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Chat
<?php
include_once 'chat.php';
$mode = $_POST['mode'];
$id = 0;
$chat = new Chat();
if ($mode == 'SendAndRetrieveNew') {
$name = $_POST['name'];
$message = $_POST['message'];
$color = $_POST['color'];
$id = $_POST['id'];
if ($name != '' && $message != '' && $color != '') {
$chat->postNewMessages($name, $message, $color);
}
} else {
if ($mode == 'DeleteAndRetrieveNew') {
$chat->deleteAllMessages();
} else {
if ($mode == 'RetriveNew') {
$id = $_POST['id'];
}
}
}
if (ob_get_length()) {
ob_clean();
}
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/xml');
echo $chat->getNewMessages($id);
示例2: header
{
header('HTTP/1.1 500 ' . clean($message));
print '<p>' . clean($message) . '</p>';
die;
}
}
// ---------------------------------------------------
// Let's do some maagic
// ---------------------------------------------------
define('ENVIRONMENT_PATH', realpath(dirname(__FILE__) . '/..'));
define('ENVIRONMENT', substr(ENVIRONMENT_PATH, strrpos(ENVIRONMENT_PATH, '/') + 1));
$chat = new Chat($_POST);
$chat->addTextMessages();
header('Content-Type: text/html; charset=utf-8');
// Print new message command if any
$new_messages = $chat->getNewMessages();
if (is_array($new_messages)) {
foreach ($new_messages as $new_message) {
if ($new_message['type'] == 'message') {
print 'App.Chat.add_message(' . var_export($new_message['content'], true) . ', {
author: {
"id" : ' . $new_message['created_by_id'] . ',
"display" : ' . var_export($new_message['created_by_name'], true) . ',
"avatar" : ' . var_export($chat->getUserAvatarUrl($new_message['created_by_id'], true), true) . '
},
message_id : ' . $new_message['id'] . ',
created_on : ' . var_export($new_message['created_on'], true) . ',
silent : true
});';
} else {
print 'App.Chat.add_message(' . var_export($new_message['content'], true) . ', {