Answer the question
In order to leave comments, you need to log in
How to get the correct request from the VK Community API?
Good day! I encountered such a problem when working with the VK API . I
use the API for communities. It is necessary to pull out dialogs in which there are unread messages.
There is a function:
public function request($method,$params=array())
{
$uri = 'https://api.vk.com/method/'.$method;
$params['access_token'] = $this->token;
$params['v'] = '5.53';
return json_decode(file_get_contents($uri.'?'.http_build_query($params)),true);
}
public function unread()
{
return $response = $this->request('messages.getDialogs',
[
'count'=>'20',
'unread'=>'1',
'offset'=>'-20',
'start_message_id'=>1
]);
}
[
"response" => [
"count" => 12
"real_offset" => 12
"unread_dialogs" => 1
"items" => []
]
]
https://api.vk.com/method/messages.getDialogs?v=5.53&access_token={API_TOKEN}&count=20&offset=-20&unread=1&start_message_id=1
{
"response": {
"count": 1,
"real_offset": -8,
"items": [
{
"unread": 1,
"message": {
"id": 150,
"date": 1474366312,
"out": 0,
"user_id": 01111111,
"read_state": 0,
"title": " ... ",
"body": "проверка"
},
"in_read": 149,
"out_read": 149
}
]
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question