Answer the question
In order to leave comments, you need to log in
Uploading files to VK. Via VK API. What am I doing wrong?
Good afternoon!
There is a download code:
$server = $this->request('photos.getWallUploadServer', [
'group_id' => $groupId
]);
$uploadDir = $server->upload_url;
$ch = curl_init($uploadDir);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POSTFIELDS, ['photo' => '@'.realpath('C:/www/OpenServer/domains/srv/web/images/wall/1/12.jpg')]);
$otvet = curl_exec($ch);
curl_close($ch);
var_dump($otvet);
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