SpotifyWebAPI\SpotifyWebAPI::replaceUserPlaylistTracks PHP Метод

replaceUserPlaylistTracks() публичный Метод

Requires a valid access token. https://developer.spotify.com/web-api/replace-playlists-tracks/
public replaceUserPlaylistTracks ( string $userId, string $playlistId, string | array $tracks ) : boolean
$userId string ID of the user.
$playlistId string ID of the playlist.
$tracks string | array ID(s) of the track(s) to add.
Результат boolean Whether the tracks was successfully replaced.
    public function replaceUserPlaylistTracks($userId, $playlistId, $tracks)
    {
        $tracks = $this->idToUri($tracks);
        $tracks = json_encode(['uris' => (array) $tracks]);
        $headers = $this->authHeaders();
        $headers['Content-Type'] = 'application/json';
        $uri = '/v1/users/' . $userId . '/playlists/' . $playlistId . '/tracks';
        $this->lastResponse = $this->request->api('PUT', $uri, $tracks, $headers);
        return $this->lastResponse['status'] == 201;
    }