Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

python - 如何使用Spotify API Python让其他用户最近播放过歌曲(How to get other user recently played song using Spotify API Python)

I get a college task , to get recently played song using Spotify API and Python language.

(我要完成一项大学任务,以便使用Spotify API和Python语言获得最近播放的歌曲。)

the problem is i just can get MY recently played song only.

(问题是我只能获得我最近播放的歌曲。)

The task is getting other's too.

(任务也越来越多。)

This my code so far:

(到目前为止,这是我的代码:)

import requests


response =requests.get("https://api.spotify.com/v1/me/player/recently-played", 
               headers={"Content-Type":"application/json", 
                        "Authorization":"Bearer TOKEN"})

json_response = response.json()

for i in json_response['items']:
    print(i["track"]['name'])
  ask by Hjin translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have not worked with the Spotify API previously, but it seems that all you should need to do is to change the token to the token of the user you are trying to get the recently played song of.

(以前我没有使用Spotify API,但是似乎您需要做的就是将令牌更改为尝试获取其最近播放的歌曲的用户的令牌。)

It should not be possible to get the recently played songs of other users without some form of authentication.

(如果没有某种形式的验证,就不可能获得其他用户最近播放的歌曲。)

As long as you are provided with the token of the other users of course.

(当然,只要为您提供其他用户的令牌即可。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...