简体   繁体   中英

Spotify oEmbed API stopped working

Until recently, I could query the Spotify oEmbed API for an embed snippet by requesting https://embed.spotify.com/oembed/?url=<track_url>&format=json

Since then, it still works in the browser or via wget , but it does not work anymore programmatically via eg Ruby:

Net::HTTP.get_response(oembed_url)

This now returns a blank string and 200 Status Code (success). What changed? Does it need specific HTTP headers?

It turns out, it requires a User Agent. I guess this is a pretty standard practice but a tiny tweet from @SpotifyPlatform would have been appreciated.

Be careful not to use a nondescript user agent like eg Ruby but rather something specific like the name of your app to avoid running into quota limitations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM