Y
Y
yischyk2019-08-05 17:42:43
In contact with
yischyk, 2019-08-05 17:42:43

Why an empty photo sheet?

$token = 'TOKEN';
$group_id = 'GID';
$album_id = 'AID';
$v = '5.101'; 
 
$image_path = dirname(__FILE__).'/111.jpg';// путь до картинки
$post_data = array("file1" => '@'.$image_path);

// получаем урл для загрузки
 $url = file_get_contents("https://api.vk.com/method/photos.getUploadServer?album_id=".$album_id."&group_id=".$group_id."&access_token=".$token."&v=".$v);
$url = json_decode($url)->response->upload_url;
//print_r($url);

// отправка post картинки
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = json_decode(curl_exec($ch),true);
//print_r($result);

// сохраняем
$safe = file_get_contents("https://api.vk.com/method/photos.save?server=".$result['server']."&photos_list=".$result['photos_list']."&album_id=".$result['aid']."&hash=".$result['hash']."&group_id=".$group_id."&access_token=".$token."&v=".$v);
$safe = json_decode($safe,true);
print_r($safe);

but for some reason photos_list is empty

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