当前位置: 首页>>代码示例>>PHP>>正文


PHP Activity::getMessage方法代码示例

本文整理汇总了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();
开发者ID:ReneGustavo,项目名称:realtime-web-workshop,代码行数:31,代码来源:index.php

示例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':
开发者ID:rwwaskk,项目名称:html5-realtime-activity-streams,代码行数:31,代码来源:trigger_activity.php


注:本文中的Activity::getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。