Answer the question
In order to leave comments, you need to log in
How to shove sending a request to vk api into a function?
I can not shove sending requests (for example, to send messages) to vk api into a separate function. Outside the function, requests are sent.
Here are two functions:
The first (for example) works
function logUpdate($message)
{
$dateTime = date("Y-m-d H:i:s");
$fp = fopen('log.txt', 'a');
$test = fwrite($fp, "[{$dateTime}] " . $message . "<br>");
fclose($fp);
}
function VKMessage($_message, $_userId, $_token)
{
$request_params = array(
'message' => $_userPostsCount,
'user_id' => $_userId,
'access_token' => $_token,
'v' => '5.0'
);
$get_params = http_build_query($request_params);
file_get_contents('https://api.vk.com/method/messages.send?' . $get_params);
}
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