PHP code example of sonrac / yandex-music-api

1. Go to this page and download the library: Download sonrac/yandex-music-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sonrac / yandex-music-api example snippets


use sonrac\YandexMusic\Yandex;

$api = new Yandex('username', 'password');

use sonrac\YandexMusic\Yandex;

$api = new Yandex('username', 'password', true);

$accountStatus = $api->getAccountStatus();

$feed = $api->getFeed();

$genres = $api->getGenres();

$searchResult = $api->search('text', 0);


// For current user
$playLists = $api->getUserPlayLists();

// For some user with uid 1000
$playLists = $api->getUserPlayLists(1000);

* Get play list


$playlists = $api->getPlayLists([1003, 1010]);

$playlists = $api->getPlayLists([1003, 1010]);

$resultRemove = $api->removePlaylist(1003);

$resultRename = $api->renamePlaylist(1003, 'new playlist');

$resultRename = $api->addTrackToPlaylist(1003, [1,2,3,4]);

$resultRename = $api->removeTracksFromPlaylist(1003, [1,2,3,4]);