Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

WebPlayer SDK API - play song by #ID

WebPlayer SDK API - play song by #ID

Hello,

 

I am looking here

https://developer.spotify.com/documentation/web-playback-sdk/

 

Is there a way to play song by #ID on our own site?

 

Thank you

Reply
12 Replies

There is a description here - https://developer.spotify.com/documentation/web-playback-sdk/reference/#playing-a-spotify-uri of how to use the Web API to trigger playback on your device.  You can get the device ID from the "ready" event listener.

Thank you. I found the way.

I now looking to receive Access Token with PHP

I found good example here
https://stackoverflow.com/questions/71370356/obtain-spotify-api-oauth-2-0-token-with-php

But that access token returned from that API is 2 times shorter and does not work.

Could you help me please?

Regards,
Oleg

It returns like in console
GET https://api.spotify.com/v1/melody/v1/check_scope?scope=web-playback 403
It is recommended that a robustness level be specified. Not specifying the robustness level could result in unexpected behavior.
POST https://api.spotify.com/v1/track-playback/v1/devices 400

I'm not so sure exactly what your issue is specifically, but I can tell you that the SO page you linked to allows you to get an Access Token using the Client Credentials OAuth flow.  This token will not be sufficient for use for the Web Playback SDK - you should instead be using the Authorization Code Flow (https://developer.spotify.com/documentation/general/guides/authorization/code-flow/

Hello,

Thank you. Here it looks like we manually need to login. We need some automatic way to receive Access token.

Is there any way for that?

Regards,
Oleg

You only need the user to authorise access once, after that you can use the provided refresh token to refresh your access token.

Thank you for your reply.

I use this
https://accounts.spotify.com/authorize?response_type=code&state=&client_id=[ClientId]&scope=user-rea...

And it returns me this error
INVALID_CLIENT: Invalid redirect URI

I use correct Client #ID as I am able to get Access Token from previous curl.

I figured out. Now I am looking to get scope for auth. I will keep you posted.

I figured out for now how I can do that. Thank you. I will keep you posted.

Thank you very much for all your help.

I wonder can we display some controls? I am looking here
https://developer.spotify.com/documentation/web-playback-sdk/reference/

But may be there is some already made example with track line and some other buttons like volume?

Hello,

Sorry I am trying to create Spotify player myself. I am in issue where I need to move track line slider.

So I need to trigger event "player_state_changed" every second to update track line position.

Could you help with it please? I can setInterval for every second to trigger it.

Regards,
Oleg

I was able to find it. Sorry.

Suggested posts