Answer the question
In order to leave comments, you need to log in
How to remove Yandex Disk API error?
function createDirectory($path)
{
$diskClient = new DiskClient(ACCESS_TOKEN);
$diskClient->setServiceScheme(DiskClient::HTTPS_SCHEME);
$dirContent = $diskClient->createDirectory($path);
if ($dirContent) return 'Создана новая директория "' . $path;
}
echo createDirectory('тест55');
Fatal error: Uncaught Yandex\Disk\Exception\DiskRequestException: Service responded with error code: "405" and message: "Method Not Allowed" in /yandex/libs/nixsolutions/yandex-php-library/src/Yandex/Disk/DiskClient .php:109 Stack trace: #0 /yandex/libs/nixsolutions/yandex-php-library/src/Yandex/Disk/DiskClient.php(126): Yandex\Disk\DiskClient->sendRequest('MKCOL', '\ xD1\x82\xD0\xB5\xD1\x81\xD1\x8255') #1 /yandex/yandex.functions.php(81): Yandex\Disk\DiskClient->createDirectory('\xD1\x82\xD0\xB5\ xD1\x81\xD1\x8255') #2 /yandex/yandex.disk.php(45): createDirectory('\xD1\x82\xD0\xB5\xD1\x81\xD1\x8255') #3 {main} thrown in /yandex/libs/nixsolutions/yandex-php-library/src/Yandex/Disk/DiskClient.php on line 109
Answer the question
In order to leave comments, you need to log in
function createDirectory($path)
{
$diskClient = new DiskClient(ACCESS_TOKEN);
$diskClient->setServiceScheme(DiskClient::HTTPS_SCHEME);
try {
$dirContent = $diskClient->createDirectory($path);
if ($dirContent) {
return 'Создана новая директория "' . $path;
}
} catch (\Yandex\Disk\Exception\DiskRequestException $e) {
return "Директория {$path} уже существует";
}
}
echo createDirectory('тест55');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question