Add sendmsg
API
This commit is contained in:
parent
32a9f49ecb
commit
c9b7bc87d5
12
api.php
12
api.php
@ -151,7 +151,17 @@ switch ($VARS['action']) {
|
|||||||
}
|
}
|
||||||
die('{"status": "OK", "msg": "Task updated."}');
|
die('{"status": "OK", "msg": "Task updated."}');
|
||||||
case "sendmsg":
|
case "sendmsg":
|
||||||
|
$msg = strip_tags($VARS['msg']);
|
||||||
|
if (user_exists($VARS['to'])) {
|
||||||
|
$to = getUserByUsername($VARS['to'])['uid'];
|
||||||
|
} else {
|
||||||
|
die('{"status": "ERROR", "msg": "Invalid user."}');
|
||||||
|
}
|
||||||
|
if (is_empty($msg)) {
|
||||||
|
die('{"status": "ERROR", "msg": "Missing message."}');
|
||||||
|
}
|
||||||
|
$database->insert('messages', ['messagetext' => $msg, 'messagedate' => date("Y-m-d H:i:s"), 'from' => $userinfo['uid'], 'to' => $to]);
|
||||||
|
die('{"status": "OK"}');
|
||||||
default:
|
default:
|
||||||
header("HTTP/1.1 400 Bad Request");
|
header("HTTP/1.1 400 Bad Request");
|
||||||
die("\"400 Bad Request\"");
|
die("\"400 Bad Request\"");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user