Y
Y
yischyk2019-08-05 16:19:43
PHP
yischyk, 2019-08-05 16:19:43

Why is photos_list empty?

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

in the end it gives (see here a0316623.xsph.ru/test.php)
why the photo sheet is empty?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey, 2019-08-05
@yischyk

The link gives an error 100, one of the parameters is incorrect. Maybe the token is old, or they forgot to put a minus sign in the groupID (it seems like it should be there). I can throw off a similar code for loading, however, avatars, but the meaning is the same

A
Alexander Aksentiev, 2019-08-05
@Sanasol

Most likely because your php is newer than 2013.
https://wiki.php.net/rfc/curl-file-upload
Sending via @ has been deprecated for a long time.
https://www.php.net/manual/en/curlfile.construct.php

// Create a cURL handle
$ch = curl_init('http://example.com/upload.php');

// Create a CURLFile object
$cfile = new CURLFile('cats.jpg','image/jpeg','test_name');

// Assign POST data
$data = array('test_file' => $cfile);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// Execute the handle
curl_exec($ch);

L
lodas, 2017-12-10
@Toxa26

For .prof-left and .prof-right, set the width as a percentage, i.e. for example .prof-left {width:30%;} and .prof-right {width:70%;}. You can choose the percentage at the maximum possible width of the main block.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question