我正在尝试使用Python在Spotify上播放当前播放的歌曲:
def get_currently_played_song():
response = requests.post(
'https://accounts.spotify.com/api/token',
data={
'grant_type': 'client_credentials'
},
auth=(SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET)
)
access_token = response.json()['access_token']
current_song = requests.get(
'https://api.spotify.com/v1/me/player/currently-playing',
headers={
'Authorization': f'Bearer {access_token}'
}
)
print(current_song)
但是,我得到的是404。我认为端点是错误的,但是我不确定是否应该替换URL中的某些内容。我尝试用Spotify用户名替换“我”,但是问题仍然存在。