Answer the question
In order to leave comments, you need to log in
How to properly use attachments in Callback API?
I am writing a bot for the VKontakte community. You need to make sure that the bot attaches a photo from the community album to the message.
What is the best way to write code?
Here is an example of his response:
}elseif (strpos($user_msg, 'помощь') !== false) {
$v->msgsend("мои команды", $uid, $token);
Answer the question
In order to leave comments, you need to log in
The documentation for the messages.send()
method describes the field attachment
. This field simply contains lines of the type separated by commas photo-123_456
, identifying the attached pictures.
Modify your submit method:
public function msgSend($msg, $uid, $token, $attachment = '' ){
$request_params = array(
'message' => $msg,
'user_id' => $uid,
'attachment' => $attachment,
'access_token' => $token,
'v' => self::API_VERSION
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question