B
B
bora24rus2016-12-06 20:05:27
CMS
bora24rus, 2016-12-06 20:05:27

Is it possible to insert the contents of an open folder on Yandex.disk into the page code?

Hello everyone, I was looking for such a function in the Yandex.disk API, I did not find anything. I keep a file dump for the site of an educational institution on Yandex.disk, so as not to clog up the space on the hosting. Often you have to put new documents on the site, sometimes very weighty ones. I thought it would be convenient to insert a clickable list of files in a shared folder into the page code, so as not to manually link to each file, or just to the folder. Sometimes the authorities checking school sites do not like it when they simply post a link to a folder in Yandex.disk with a bunch of documents uploaded there, allegedly "this information is not already on the site, but somewhere there" they ask to redo it. Approximately how it would look like I tried to depict in FS. Does anyone know if this can be done? If not, it would be cool if developers implement this in the disk API.6d73b25f65964b889dab232ab5abfa4f.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-12-18
@AaAAxzz

Hello. It is very easy to do, the simplest PHP code might look like this:

$disk = new Arhitector\Yandex\Disk($client); // тут  указать access token
$dir = $disk->getResource('/'); // путь к папке на диске

foreach ($dir->items as $item)
{
  if ( ! $item->isFile())
  {
    continue;
  }
  // URL, если файл открыт или ссылка на Doc viewer
  echo '<a href="'.$item->get('public_url', $item->docviewer).'">'.$item->name.'</a><br />';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question