Spotify API添加到播放列表

Spotify API添加到播放列表,api,spotify,Api,Spotify,是否可以通过服务器端功能操纵(添加)Spotify播放列表 web API似乎仅限于搜索(https://developer.spotify.com/technologies/web-api/)而具有该功能的JavaScript API参考似乎仅限于在Spotify内部实际构建应用程序…不幸的是,如果不使用JS API在客户端内部构建Spotify应用程序,或者使用Libsotify在独立应用程序中构建Spotify应用程序,则此时不可能做到这一点。是的,您可以,但您需要一个涉及用户的授权过程,

是否可以通过服务器端功能操纵(添加)Spotify播放列表


web API似乎仅限于搜索(https://developer.spotify.com/technologies/web-api/)而具有该功能的JavaScript API参考似乎仅限于在Spotify内部实际构建应用程序…

不幸的是,如果不使用JS API在客户端内部构建Spotify应用程序,或者使用Libsotify在独立应用程序中构建Spotify应用程序,则此时不可能做到这一点。

是的,您可以,但您需要一个涉及用户的授权过程,这非常痛苦

您需要使用正确的API

资料来源:

例如,要添加轨迹,您将需要此端点

{user_id}/playlists/{playlist_id}/曲目

这些代码适用于AppleScript,只是为了证明这一概念:

set userID to "XXXXX"
-- your userID can be retrieved with https://developer.spotify.com/web-api/console/get-current-user/#complete

set SelectedPlaylistID to "YYYY"
-- your target playlist can be retrieved with https://developer.spotify.com/web-api/console/get-playlists/#complete

set BearerID to "ZZZZ"
-- ZZZZ can be retrieved manually on page https://developer.spotify.com/web-api/console/post-playlist-tracks/ 

tell application "Spotify"
    set currentSpotifyID to id of current track as string
end tell
set currentlyPlayingTrack to trim_line(currentSpotifyID, "spotify:track:", 0)


set theURL to "'https://api.spotify.com/v1/users/" & userID & "/playlists/" & SelectedPlaylistID & "/tracks?uris=spotify%3Atrack%3A" & currentlyPlayingTrack & "' -H 'Accept: application/json' -H 'Authorization: Bearer " & BearerID & "'"
-- obtenu de https://developer.spotify.com/web-api/console/post-playlist-tracks/#complete

set theCommand to "curl -X POST " & theURL

do shell script theCommand
但有一个大警告:你需要每小时刷新一次BearerID


这就是需要授权过程的地方,如果您想绕过刷新限制,授权过程会变得复杂。

您可以通过服务器与Spotify应用程序对话吗?Libsotify如何与Spotify对话?它是与本地客户端还是远程服务器通信?它与远程服务器通信。您希望代表用户(也称为oauth流)还是仅为您自己的用户操纵播放列表?