//include_once 'Chat.php'; #$data = '{"action": "getmsg", "phone": "2347066192100"}'; #$data = '{"action":"receiverstatusmsg","receiver":"2348105364269","status":"w"}'; #$data = '{"action":"msgbystatus","phone":"2347066192100","status":"r #$data = '{"action":"msgbychatkey","chatkey":"23470661921002348105364269"}' # $data = '{"action": "update", "authkey": "770073e57a7fcf79760c1555bdc5a908","fname":"Jo","lname":"Ogbimi","email":"*****@*****.**","photo":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCABkAGQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19"}'; #$data = 'http://83.138.190.170/fuse/chat.php?json={%22action%22:%22sendmessage%22,%22msgid%22:%222347%22,%22chatkey%22:%2223470661921002348105364269%22,%22authkey%22:%22770073e57a7fcf79760c1555bdc5a908%22,%22sender%22:%222347066192100%22,%22receiver%22:%222348105364269%22,%22msgtype%22:%22text%22,%22msg%22:%22hello%20there%22,%22status%22:%22w%22}'; #exit; $chat = new Chat(); switch ($action) { case 'sendmessage': App::setJSONResponse($chat->sendMessage($request['chatkey'], $request['authkey'], $request['sender'], $request['receiver'], $request['contenttype'], $request['msgcontent'], $request['msgstatus'])); #App::setJSONResponse($chat->sendMessage($request['msgid'])); break; case 'getmsg': App::setJSONResponse($chat->getMessage($request['phone'])); #App::setJSONResponse($chat->getMessage()); break; case 'msgbystatus': App::setJSONResponse($chat->getMessageByStatus($request['phone'], $request['status'])); break; case 'receivermsg': App::setJSONResponse($chat->getreceiverMessage($request['receiver'], $request['id'])); break; case 'receiverstatusmsg': App::setJSONResponse($chat->getReceiverMsgByStatus($request['receiver'], $request['status'])); break; case 'msgbychatkey': App::setJSONResponse($chat->getMsgByChatKey($request['chatkey'])); break; case 'msgbyauthkey':
if ($user->isLogin() !== true) { echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -4, "errorMessage" => "User not login."))); exit(0); } if (@isset($_GET['action'])) { $action = $_GET['action']; if ($action === 'send') { $chat = new Chat(); if (@isset($_POST['to']) && isset($_POST['message'])) { $to = $_POST['to']; $message = $_POST['message']; echo json_encode($chat->addMessage($user->getUsername(), $to, $message, date('Y-m-d H:i:s', time()))); exit(0); } else { echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -16, "errorMessage" => "No user for to or no message."))); } } else { if ($action === 'get') { $chat = new Chat(); if (@isset($_POST['to'])) { $to = $_POST['to']; echo json_encode($chat->getMessage($user->getUsername(), $to)); exit(0); } else { echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -8, "errorMessage" => "the user for to is not find."))); } } } } else { echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -12, "errorMessage" => "Nothing to do."))); }