从 Spotify 应用程序内访问 Spotify 元数据 API?

发布于 2024-12-20 01:11:59 字数 218 浏览 3 评论 0原文

我想从 Spotify 应用程序中运行 Spotify 搜索(查找某个艺术家的曲目,我没有该艺术家的 Spotify URI,只有名称)。

我没有在 App API 中找到运行搜索的功能。另一种方法是与 ws.spotify.com 进行对话以访问 Spotify 的搜索,但这些网络服务不支持在 Spotify 应用程序中使用所需的 jsonp。

我有什么选择?

I want to run Spotify searches from within a Spotify app (to find tracks for an artist, for which I do not have a Spotify URI, only the name).

I have not found functionality in the App API to run searches. An alternative is to talk to ws.spotify.com to get to Spotify's search, but these web services do not support jsonp which is required for their use in a Spotify app.

What are my options?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

執念 2024-12-27 01:11:59

则可以使用 sp.core.search sp.core.getMetadata

sp.core.search("query",
    {onSuccess: function(result) {
        // parse result
        }
    }
);

如果您有 uri,

    sp.core.getMetadata("uri", {
        onSuccess: function(data){
            console.debug(data);
        },
        onFailure: function(){
                //...
        },
    });

You can use sp.core.search

sp.core.search("query",
    {onSuccess: function(result) {
        // parse result
        }
    }
);

sp.core.getMetadata if you have the uri

    sp.core.getMetadata("uri", {
        onSuccess: function(data){
            console.debug(data);
        },
        onFailure: function(){
                //...
        },
    });
风轻花落早 2024-12-27 01:11:59

这不是解决您的问题的最佳方法。有一个直接的 API 可用于在您的应用程序中进行搜索。请参阅 Juan 的解决方案。

但是,当您将域添加到应用的 manifest.json 时,您也可以直接与 ws.spotify.com 对话。

"RequiredPermissions": ["http://ws.spotify.com" ]

例如 http://ws.spotify.com/search/1/track.json?q=kaizers+orchestra,查看他们的
开发者网站。响应包含标头“Access-Control-Allow-Origin: *”,因此您应该能够从应用程序内进行查询。

This is not the finest way to solve your problem. There is a direct API for searching within your app. See Juan's solution.

But you could also talk to ws.spotify.com directly when you add the domain to your app's manifest.json.

"RequiredPermissions": ["http://ws.spotify.com" ]

e.g. http://ws.spotify.com/search/1/track.json?q=kaizers+orchestra, see their
Developer Site. The response contains the header "Access-Control-Allow-Origin: *", so you should be able to query from within your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文