I
I
Iossarian2020-06-18 12:43:20
PHP
Iossarian, 2020-06-18 12:43:20

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);

Here I note that $url is correct, and file_exist($filename) returns true
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;


Actually, I can not understand why null and what he does not like?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question