Soundcloud API - 由歌手跟踪


Soundcloud Api - get track by singer

嗨,我想在音频部分创建同样的东西,所以当我输入歌手的名字时,它会通过其 API 向我发送该歌手的 Json 数据以及 soundcloud 网站中的所有可用曲目。

这是我现在正在尝试的代码:

    <script src="http://connect.soundcloud.com/sdk.js"></script>
    <script>
        SC.initialize({
          client_id: 'Client_ID'
        });
        // stream track id 293
        SC.stream("/tracks/293", function(sound){
          sound.play();
        });
    </script>

因此,如您所见,从以下链接中从soundcloud API获取曲目ID很简单:http://api.soundcloud.com/tracks/13158665.json?client_id=YOUR_CLIENT_ID

但我想要的是将特定歌手的这些 ID 作为参数传递给函数,所有这些都使用 Javascript,否则请使用 PHP。

您可以使用

q参数点击/users端点,以尝试匹配艺术家姓名:

SC.get('/users', {q: 'rihanna'}, function (users) {
  console.log(users);
  // iterate over users, do the matching
  // hit the users api link, get tracks and stream them via their IDs
});

在此处查看示例 – http://jsbin.com/xugomagami/1/edit?html,js,console,output