Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
直到最近,我可以通过请求查询 Spotify oEmbed API 以获取嵌入片段https://embed.spotify.com/oembed/?url=<track_url>&format=json
https://embed.spotify.com/oembed/?url=<track_url>&format=json
从那时起,它仍然可以在浏览器或 viawget中工作,但它不再通过例如 Ruby 以编程方式工作:
wget
Net::HTTP.get_response(oembed_url)
现在返回一个空白字符串和 200 状态码(成功)。发生了什么变化?它是否需要特定的 HTTP 标头?
事实证明,它需要一个用户代理。我想这是一种非常标准的做法,但来自@SpotifyPlatform 的一条小推文会受到赞赏。
注意不要使用像 eg 这样的不起眼的用户代理Ruby,而是使用特定的东西,比如你的应用程序的名称,以避免遇到配额限制。
Ruby