Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
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.
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 questionAsk a Question
731 491 924 answers to any question