我想知道是否可以播放Spotify with Python(如果可能的话2.7版)的歌曲以及如何播放.
无论如何从它的URI启动Spotify Track?
我尝试了以下方法,但没有一个工作.当Spotify打开时,它总是落在播放列表页面中,而不是轨道播放器.
String spotifyTrackURI = "spotify:track:1cC9YJ8sQjC0T5H1fXMUT2";
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.spotify.mobile.android.ui");
// I've tried with Intent#putExtra()..
launchIntent.putExtra( SearchManager.QUERY, spotifyTrackURI );
// or with setData
launchIntent.setData(Uri.parse(spotifyTrackURI))
context.startActivity(launchIntent);
Run Code Online (Sandbox Code Playgroud)
谢谢
我刚刚在Spotify for Android设置屏幕中找到了此设置选项:
"设备广播状态 - 允许您设备上的其他应用看到您正在收听的信息"
我猜这意味着任何其他应用都可以通过Spotify访问正在播放的内容.如何实施?周围有文件吗?
谢谢
我目前正在使用 Spring Security + OAUth2 协议构建 Spring Boot 应用程序。
我无法理解如何执行授权代码流程的步骤 2 - 4。我能够获得授权并获得授权代码来交换访问和刷新令牌,但我不确定如何获取令牌,然后开始进行 API 调用。
阅读 Spring 文档让我对某些事情感到困惑。
这是我的 application.properties
#
# OAuth ClientRegistration Properties
#
spring.security.oauth2.client.registration.spotify.client-id=#
spring.security.oauth2.client.registration.spotify.client-secret=#
spring.security.oauth2.client.registration.spotify.provider=spotify-provider
spring.security.oauth2.client.registration.spotify.client-authentication-method=basic
spring.security.oauth2.client.registration.spotify.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.spotify.redirect-uri=http://localhost:8080/redirect
spring.security.oauth2.client.registration.spotify.scope=user-read-private,user-read-email
#
# OAuth ProviderDetails Properties
#
spring.security.oauth2.client.provider.spotify-provider.authorization-
uri=https://accounts.spotify.com/authorize?show_dialog=true
spring.security.oauth2.client.provider.spotify-provider.token-
uri=https://accounts.spotify.com/api/token
spring.security.oauth2.client.provider.spotify-provider.user-info-uri=https://api.spotify.com/v1/me
spring.security.oauth2.client.provider.spotify-provider.user-name-attribute=id
Run Code Online (Sandbox Code Playgroud)
这是我的 WebSecurityConfig
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected …Run Code Online (Sandbox Code Playgroud) spring-security spotify oauth-2.0 spring-boot spring-security-oauth2
我目前正在开发一个实现Spotify API的Android应用程序.我已经将所有代码连接到我的应用程序以使用教程进行spotify,并且已经在我的应用程序上工作了一段时间.当我在验证用户身份后通过我的应用程序播放歌曲时,它可以很好地工作,就在我的模拟器上.当我将它切换到我的手机时,它无法正常工作,并在android响应中给了我一个INVALID_APP_ID错误.当我卸载Spotify关闭我的手机,然后尝试登录通过我的应用程序spotify,然后我能够从我的手机播放音乐没有任何崩溃.所以我的问题是如何解决这个问题?这是我验证用户的代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// Check if result comes from the correct activity
if (requestCode == requestcode) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
if (response.getType() == AuthenticationResponse.Type.TOKEN) {
Config playerConfig = new Config(this, response.getAccessToken(), client_id);
token = response.getAccessToken();
Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
@Override
public void onInitialized(Player player) {
mPlayer = player;
mPlayer.addConnectionStateCallback(.this);
mPlayer.addPlayerNotificationCallback(.this);
}
@Override
public void onError(Throwable throwable) {
Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage()); …Run Code Online (Sandbox Code Playgroud) 如何从应用程序(Windows/Mac)获取音乐播放,倾斜,艺术家等数据.有一个使用Web API的选项,但我测试了Musixmatch应用程序,即使我离线也可以工作,因此可以某种方式连接到应用程序.
我试图在Spotify播放器中添加(向前移动)10秒的歌曲持续时间或减去(向后移动)10秒,但是我真的很困惑如何添加或减去。
当我尝试使用此代码时,歌曲的持续时间不会改变
// forward button action
@IBAction func moveFrdBtnAction(_ sender: Any) {
SpotifyManager.shared.audioStreaming(SpotifyManager.shared.player, didSeekToPosition: TimeInterval(10))
}
// spotify delegate method seekToPosition
func audioStreaming(_ audioStreaming: SPTAudioStreamingController!, didSeekToPosition position: TimeInterval) {
player?.seek(to: position, callback: { (error) in
let songDuration = audioStreaming.metadata.currentTrack?.duration as Any as! Double
self.delegate?.getSongTime(timeCount: Int(songDuration)+1)
})
}
Run Code Online (Sandbox Code Playgroud)
我们正在两个平台(Android和iOS)上使用相同的SDK制作音乐应用程序,Spotify SDK的seekToPosition方法在Android版本中正常运行,但是在iOS版本中不起作用。委托方法调用本身,但音乐停止了。
您能否告诉我们为什么会发生这种情况,以及我们应该怎么做才能在iOS设备上运行它。
有人可以向我解释如何解决这个问题,我已经尝试解决这个问题,但没有结果。
任何帮助将不胜感激。
提前致谢。
我正在使用 Spotify API 开发一个应用程序。我的问题是我正在尝试获取access_token但它不起作用。在文档中,它说我需要发送编码为 application/x-www-form-urlencoded 的正文,所以我搜索了一下,它应该只需设置request_body为字典即可工作。
这是我的函数的代码:
def get_access_token(self):
auth_code, code_verifier = self.get_auth_code()
endpoint = "https://accounts.spotify.com/api/token"
# as docs said data should be encoded as application/x-www-form-urlencoded
# as internet says i just need to send it as a dictionary. However it's not working
request_body = {
"client_id": f"{self.client_ID}",
"grant_type": "authorization_code",
"code": f"{auth_code}",
"redirect_uri": f"{self.redirect_uri}",
"code_verifier": f"{code_verifier}"
}
response = requests.post(endpoint, data=request_body)
print(response)
Run Code Online (Sandbox Code Playgroud)
我得到的回应始终是<Response [400]>
这里是文档,步骤 4 https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow-with-proof-key-for- code-exchange-pkce
注意:我尝试将其作为curl执行,它工作正常,我不确定我在python代码中做错了什么,命令如下:
curl -d client_id={self.client_ID} -d grant_type=authorization_code -d …Run Code Online (Sandbox Code Playgroud) 编辑:澄清一下,获取授权代码按预期工作。这纯粹是用授权码交换令牌的步骤失败了。
我正在尝试使用 PKCE 流程实现授权代码,以便使用 Spotify API 进行身份验证。我知道有一些库可以实现这一点,但我真的想自己实现它。我所说的流程是这样的: https: //developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow-with-proof-key-for-code-exchange-pkce 我我能够制作链接以将用户重定向到同意页面并获取授权代码。但是,当我尝试将此代码交换为令牌时,我收到一个 400 错误请求,其中包含消息“无效的 client_secret”。这让我相信 Spotify 假设我正在尝试使用常规授权代码流程,因为客户端密钥根本不是 PKCE 流程的一部分。我怀疑我对 code_verifier 或 code_challenge 的编码错误。我在 SO(How tocalculate PCKE's code_verifier?)上找到了这个答案,并将其翻译为 C#,为 Base64 编码的哈希产生相同的结果,但它仍然不起作用。
下面是我生成 code_verifier 和 code_challenge 的代码,以及发出交换代码请求的代码。
代码验证器:
private string GenerateNonce()
{
const string chars = "abcdefghijklmnopqrstuvwxyz123456789";
var random = new Random();
var nonce = new char[100];
for (int i = 0; i < nonce.Length; i++)
{
nonce[i] = chars[random.Next(chars.Length)];
}
return new string(nonce);
}
Run Code Online (Sandbox Code Playgroud)
代码挑战:
private string GenerateCodeChallenge(string codeVerifier)
{
using …Run Code Online (Sandbox Code Playgroud) 
这是我第一次看到这样的按钮(见右侧).单击该按钮可启动Spotify.Spotify如何为他们的电子邮件做到这一点?现在可以用其他应用程序完成吗?
spotify ×10
android ×3
oauth-2.0 ×2
python ×2
c# ×1
duration ×1
gmail ×1
ios ×1
libspotify ×1
oauth ×1
post ×1
python-2.7 ×1
spotify-app ×1
spring-boot ×1
swift ×1