This is a WordPress plugin that allows you to perform any operations with your Yandex.Disk.
$ cd /var/www/my-domain.com/wp-content/plugins
$ git clone https://github.com/aslanbaryshnikov/yd-api-provider
$ php yd-api-provider/composer.phar install --no-dev --optimize-autoloader
After the plugin is installed, don't forget to activate it on your site.
Go to the page for creating an application on Yandex. You need to fill in the following parameters:
- Application name. Enter any, because it doesn't affect anything.
- In the Platforms section, check the box Web services.
- Click on "Submit URL for development".
Then you must grant the application the following rights:
- Record anywhere on the Disk
- Reading the entire Disk
- Access to information about the Disk
- Access to the application folder on Disk
After that, click on the Create Application button. This will open a page with information about the created application. Copy the ID, you will need it in the next step.
Next, you need to get a token for your application. To do this, go to
https://oauth.yandex.ru/authorize?response_type=token&client_id=APPLICATION_ID
and allow the application to work with your Yandex.Disk. You will be redirected to a page with a token that will be valid for the next 365 days, but remember that you can always get a new token. Copy it and paste into the input field on the plugin settings page on your site. Save your changes.
If you still have questions, you can learn the instructions for getting a token from Yandex.
The plugin uses PHP SDK for Yandex.Disk and provides a global YD_API_Provider class, through which you can perform any operations with Disk. You can check the available methods here.
add_action('plugins_loaded', 'my_func');
function my_func() {
$YandexDisk = YD_API_Provider::get_instance();
echo $YandexDisk->total_space;
}