S
S
Ssshivaaa2017-05-10 18:03:34
PHP
Ssshivaaa, 2017-05-10 18:03:34

Why is the photo array empty VK API CURL PHP?

copy($photo_url, $_SERVER['DOCUMENT_ROOT'].'/tmp/img.jpg'); //Save the photo using the link to the server
$upload_url = json_decode(file_get_contents(" https://api.vk.com/method/photos.getMessagesUpload... ".$token))->response->upload_url; //Get the upload address
$post_params = array(
'photo' => $_SERVER['DOCUMENT_ROOT'].'/tmp/img.jpg'
);
$ch = curl_init($upload_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$response = curl_exec($ch);
curl_close($ch);
In response I get an empty array photo[] :(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Serezha, 2017-05-10
@Ssshivaaa

How to upload a photo through VK api?

P
Pavel, 2017-05-10
@PavelFokeev

'photo' => '@'.$_SERVER['DOCUMENT_ROOT'].'/tmp/img.jpg'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question