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
1
require_once vendor/autoload.php;
2
$userid=1;
3
$messages=new telifoun\mqttchat\messages($userid);
4
$limit=1;
5
$result=$messages->getByPage($limit);
Copied!
1
{
2
"ok": true,
3
"data": {
4
"query": {
5
"limit": 1
6
},
7
"messages": [
8
{
9
"id": 141097,
10
"type": 0,
11
"sentAt": 1607800942,
12
"message": " hi ",
13
"read": 1,
14
"readAt": 1607851559,
15
"p1": "undefined",
16
"p2": "undefined",
17
"p3": "undefined",
18
"sender": {
19
"userid": 2093,
20
"name": "فولان",
21
"surname": "بن فولان",
22
"avatar_link": "",
23
"profile_link": "",
24
"gender": 0
25
},
26
"receiver": {
27
"userid": 1,
28
"name": "Gaddour",
29
"surname": "Mohamed",
30
"avatar_link": "",
31
"profile_link": "",
32
"gender": 0
33
}
34
}
35
]
36
}
37
}
Copied!

Get Message by id

Get message informations by message id.
1
require_once vendor/autoload.php;
2
$userid=1;
3
$messages=new telifoun\mqttchat\messages($userid);
4
$messageid=141034;
5
$result=$messages->get($messageid);
Copied!
1
{
2
"ok": true,
3
"data": {
4
"id": 141034,
5
"sender_id": 1,
6
"receiver_id": 2093,
7
"type": 0,
8
"sentAt": 1607677868,
9
"message": "oui",
10
"read": 1,
11
"readAt": 1607711249,
12
"p1": "undefined",
13
"p2": "undefined",
14
"p3": "undefined"
15
}
16
}
Copied!

Delete Message by id

Delete Message by message id.
1
require_once vendor/autoload.php;
2
$userid=1;
3
$messages=new telifoun\mqttchat\messages($userid);
4
$messageid=141034;
5
$result=$messages->delete($messageid);
Copied!
1
{
2
"ok": true,
3
"data": {
4
"userid": 1,
5
"messageid": 141034
6
}
7
}
Copied!
Last modified 11mo ago