Answer the question
In order to leave comments, you need to log in
How to delay the execution of a function in php?
I am writing a bot in php for VK. The task is as follows: the bot writes "Hello", he answers "Bye", but only after 2 hours.
Here is the part of the code that is responsible for sending a response message if they write "Hi".
case strstr($message,'Привет') :
$request_params = array(
'message' => "Пока",
'user_id' => $user_id,
'access_token' => $token,
'v' => '5.0'
);
$get_params = http_build_query($request_params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/messages.send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $get_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl_close($ch); break;
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