Created
June 16, 2020 15:26
-
-
Save KhunHtetzNaing/23da3515fbb9e5add6c3370d439fa7cf to your computer and use it in GitHub Desktop.
Yadisk API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$yadisk = 'https://yadi.sk/i/d-8trVHpcT6qQA'; | |
$json = file_get_contents("https://cloud-api.yandex.net/v1/disk/public/resources/?public_key={$yadisk}"); | |
$json = json_decode($json); | |
echo 'File => ' . $json->file . 'Size => ' . sizeFilter($json->size) . 'Name => ' . $json->name; | |
function sizeFilter($bytes) | |
{ | |
$label = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); | |
for ($i = 0; $bytes >= 1024 && $i < (count($label) - 1); $bytes /= 1024, $i++); | |
return (round($bytes, 2) . " " . $label[$i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment