Spotify Web API 播放端点 - 播放曲目

Spotify Web API play endpoint - play track

我正在尝试使用 Spotify Web API 在传递曲目 ID 时播放曲目。我在 Spotify 的 API 控制台 here 上使用 PUT https://api.spotify.com/v1/me/player/play 端点。当我在 PUT 正文中使用样本数据,并添加我的设备 ID 和 OAuth 令牌并单击“试用”按钮时,歌曲开始播放。当我将 PUT 正文更改为:

{
  "context_uri": "spotify:track:4ByEFOBuLXpCqvO1kw8Wdm"
}

我收到错误:

HTTP/1.1 400 Bad Request
Content-Length: 99
Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, PATCH
Access-Control-Max-Age: 604800
Access-Control-Allow-Credentials: true
Content-Encoding: gzip
Keep-Alive: timeout=600
Server: nginx
Connection: keep-alive
Cache-Control: private, max-age=0
Date: Wed, 31 Jan 2018 00:56:54 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Authorization, Origin, Content-Type, Retry-After
Content-Type: application/json; charset=utf-8

{
  "error" : {
    "status" : 400,
    "message" : "Non supported context uri"
  }
}

关于它为什么不起作用的任何想法?

如果您查看 Spotify 的 API,trackcontext_uri 中不受支持。

Optional. Spotify URI of the context to play.
Valid contexts are albums, artists & playlists.
Example: {context_uri:"spotify:album:1Je1IMUlBXcx1Fz0WE7oPT"}

https://developer.spotify.com/web-api/start-a-users-playback/

如果你通过了:

{
  "uris": ["spotify:track:4ByEFOBuLXpCqvO1kw8Wdm"]
}

它会起作用的。您也可以在 uris 列表中传递多首歌曲。