K
K
kot25662017-06-05 20:41:15
PHP
kot2566, 2017-06-05 20:41:15

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); 
}

The second one, when called, gives the error "Uncaught Error: Call to undefined function VKMessage()"
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);
}

If you add any other code to this function (for example, calling the logUpdate function), then there will be no error, but the request to the VK API will not be executed in any case. What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2017-06-05
@kot2566

Call to undefined function vkSendMessage()
function VKMessage eh
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question