Answer the question
In order to leave comments, you need to log in
How to send a message to a conversation in php?
Hello. There is a code here:
<?php
function send($id , $message)
{
$url = 'https://api.vk.com/method/messages.send';
$params = array(
'user_id' => $id, // Кому отправляем
'message' => $message, // Что отправляем
'access_token' => 'будет потом, // access_token можно вбить хардкодом, если работа будет идти из под одного юзера
'v' => '5.37',
);
// В $result вернется id отправленного сообщения
$result = file_get_contents($url, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params)
)
)));
}
echo send(ид пользователя,'test');
?>
Answer the question
In order to leave comments, you need to log in
write for example 2000000000111 - where 1111 is the conversation number
chat_id
to transfer, then you can just111
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question