本文整理汇总了PHP中Activity::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::getMessage方法的具体用法?PHP Activity::getMessage怎么用?PHP Activity::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity::getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_encode
<?php
require_once '../../../lib/pusher/Pusher.php';
include '../../config.php';
require_once 'Activity.php';
date_default_timezone_set('UTC');
$chat_info = $_POST['chat_info'];
if (!isset($_POST['chat_info'])) {
header("HTTP/1.0 400 Bad Request");
echo 'chat_info must be provided';
}
$options = sanitise_input($chat_info);
$activity = new Activity('chat-message', $options['text'], $options);
$pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID);
$data = $activity->getMessage();
$response = $pusher->trigger(PRESENCE_CHANNEL_NAME, 'chat_message', $data, null, true);
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
$result = array('activity' => $data, 'pusherResponse' => $response);
echo json_encode($result);
function get_channel_name($http_referer)
{
// not allowed :, / % #
$pattern = "/(\\W)+/";
$channel_name = preg_replace($pattern, '-', $http_referer);
return $channel_name;
}
function sanitise_input($chat_info)
{
$email = isset($chat_info['email']) ? $chat_info['email'] : '';
$options = array();
示例2: getActionText
require_once 'lib/squeeks-Pusher-PHP/lib/Pusher.php';
require_once '../../src/php/Activity.php';
require_once 'config.php';
$activity_type = $_GET['activity_type'];
$activity_data = null;
$email = null;
if (isset($_GET['activity_data'])) {
$activity_data = $_GET['activity_data'];
}
if (isset($_GET['email'])) {
$email = $_GET['email'];
}
$action_text = getActionText($activity_type, $activity_data);
$activity = new Activity($activity_type, $action_text, $email);
$pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID);
$pusher->trigger('site-activity', $activity_type, $activity->getMessage());
/****************************************************************************************/
function getActionText($activity_type, $activity_data)
{
$action_text = 'just did something unrecognisable.';
switch ($activity_type) {
case 'page-load':
$action_text = 'just navigated to the Activity Streams example page.';
break;
case 'test-event':
$action_text = 'just clicked the <em>Send Test</em> button.';
break;
case 'scroll':
$action_text = 'just scrolled to the ' . $activity_data['position'] . ' of the page';
break;
case 'like':