Messages Management

The rest collection for messages.

Get Messages

Get all message sent or received by a specific user id.

Path params:

Name

Description

Required

limit

Number of items to return [1-100]

true

not_read

1: Get only not read messages.

0: Get all messages.

false

before_messageid

If added to request, get messages old then before_messageid else get top recents messages.

false

PHP
PHP
require_once vendor/autoload.php;
$userid=1;
$messages=new telifoun\mqttchat\messages($userid);
$limit=1;
$result=$messages->getByPage($limit);
{
"ok": true,
"data": {
"query": {
"limit": 1
},
"messages": [
{
"id": 141097,
"type": 0,
"sentAt": 1607800942,
"message": " hi ",
"read": 1,
"readAt": 1607851559,
"p1": "undefined",
"p2": "undefined",
"p3": "undefined",
"sender": {
"userid": 2093,
"name": "فولان",
"surname": "بن فولان",
"avatar_link": "",
"profile_link": "",
"gender": 0
},
"receiver": {
"userid": 1,
"name": "Gaddour",
"surname": "Mohamed",
"avatar_link": "",
"profile_link": "",
"gender": 0
}
}
]
}
}

Get Message by id

Get message informations by message id.

require_once vendor/autoload.php;
$userid=1;
$messages=new telifoun\mqttchat\messages($userid);
$messageid=141034;
$result=$messages->get($messageid);
{
"ok": true,
"data": {
"id": 141034,
"sender_id": 1,
"receiver_id": 2093,
"type": 0,
"sentAt": 1607677868,
"message": "oui",
"read": 1,
"readAt": 1607711249,
"p1": "undefined",
"p2": "undefined",
"p3": "undefined"
}
}

Delete Message by id

Delete Message by message id.

require_once vendor/autoload.php;
$userid=1;
$messages=new telifoun\mqttchat\messages($userid);
$messageid=141034;
$result=$messages->delete($messageid);
{
"ok": true,
"data": {
"userid": 1,
"messageid": 141034
}
}