A
A
Alexander2018-03-23 23:05:31
In contact with
Alexander, 2018-03-23 23:05:31

Why does the callback api vk response come several times?

I just can not "catch the moment" why the callback api vkontakte returns the result of the request several times.

...
$user_id = $data->object->user_id;
$messGO = "Тест";
msend($messGO,$user_id);
function msend($message, $user = "000000") //000000 - id админа по-умолчанию
{
    global $token, $v;
    $request_params = array('message' => $message, 'user_id' => $user, 'access_token' => $token, 'v' => $v);
    $get_params = http_build_query($request_params);
    file_get_contents('https://api.vk.com/method/messages.send?'. $get_params);
    echo ('ok');
    break;
}

As a result the script fulfills several times. Why "does not catch" the answer "ok"?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VK API, 2018-03-24
@SilimAl

On the server settings page in community management, you can view failed requests and their reason.
Most likely, the script outputs something else besides ok, such as a warning or some kind of error, because of this, the answer is considered incorrect.

Y
ytartem2, 2020-12-31
@ytartem2

I also tried to fix this for a long time. There were incorrect response text errors and the commands were passed multiple times. And I found a solution, if it's not very important where to give echo ('ok') then let's immediately after the check (from the official VK script: case 'message_new':). Helped me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question