Answer the question
In order to leave comments, you need to log in
How to send a photo on behalf of a bot?
Hello everyone, there is a code for uploading photos to the VK server:
$par = array(
'access_token' => '///',
'peer_id' => 424401660,
'v' => 5.103
);
$user = json_decode(file_get_contents('https://api.vk.com/method/photos.getMessagesUploadServer?' . urldecode(http_build_query($par))), true);
$curl_file = curl_file_create("./photos/send/",'image/jpeg','1583856373.jpg');
$ch=curl_init();
curl_setopt_array($ch,
array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $user['response']['upload_url'],
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array("photo" => $curl_file)
));
$img_attach = json_decode(curl_exec($ch), true);
print_r($img_attach);
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