Example #1
0
<?php

/**
 * OhYesChat
 * @website Link: https://github.com/lianglee/OhYesChat
 * @Package Ohyes
 * @subpackage Chat
 * @author Liang Lee
 * @copyright All right reserved Liang Lee 2014.
 * @ide The Code is Generated by Liang Lee php IDE.
 */
header('Content-Type: application/json');
$message = OhYesChat::messageValidate(get_input('message'));
$reciever = get_input('friend');
$mobile = get_input('mobile');
$sender = elgg_get_logged_in_user_entity()->guid;
$SEND = new OhYesChat();
if ($mobile == 'true') {
    $icon = elgg_view("icon/default", array('entity' => elgg_get_logged_in_user_entity(), 'size' => 'small'));
} else {
    $icon = '';
}
if ($SEND->SendMessage($reciever, $message)) {
    echo json_encode(array('message' => elgg_view('ohyes/chat/message-item', array('message' => $message, 'sender' => $sender, 'icon' => $icon))));
} else {
    echo 'send:error';
}