Answer the question
In order to leave comments, you need to log in
Why vk api cover download method returns null?
Good afternoon. Stuck on the step of sending the cover file to the server. I do the following:
$filename = '../web/covers/background-color-explosion-sky-abstact-colors-125-211.jpg';
$url = $this->PhotoUploadServer($group_id);
$photo = $this->UploadPhoto($url, $filename);
public function UploadPhoto($url, $file)
{
$data = [
'photo' => new CURLFile($file),
];
$out = $this->request($url, $data);
return $out;
}
public function request($url, $data = array()) {
$curl = curl_init();
$data['access_token'] = $this->token;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER,[
"Content-Type:multipart/form-data"
]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$out = json_decode(curl_exec($curl), true);
curl_close($curl);
return $out;
}
var_dump($out) = null;
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