使用soundcloud API获取特定用户的曲目列表

时间:2012-04-15 05:33:08

标签: api soundcloud

是否可以通过soundcloud API从特定用户获取曲目列表而无需特定用户进行身份验证?

我正在寻找类似YouTube Feed的内容:https://gdata.youtube.com/feeds/api/users/mrromandiaz/uploads?max-results=10(我已将此指向我的帐户,但用户名“mrromandiaz”可以替换为任何用户名以检索该用户的视频...

问题是,Soundcloud提供类似的东西吗?我不需要进行身份验证,发布,上传或控制任何内容......只需让用户的曲目列表显示在他们的个人资料中,而无需借助默认播放器。

2 个答案:

答案 0 :(得分:28)

是的,API端点位于/users/{user_id}/tracks。如果您没有用户ID,只有用户名(固定链接),则可以使用/resolve端点获取用户数据,包括其ID。

此处的文档:user resource和此处resolve

答案 1 :(得分:4)

要通过soundcloud API从特定用户获取曲目列表而不进行身份验证:

(javascript示例)

SC.initialize({
      client_id: "YOUR_CLIENT_ID",
      redirect_uri: "http://example.com/callback.html",
  });

/**
Once that's done you are all set and ready to call the SoundCloud API. 
**/

/**
Call to the SoundCloud API. 
Retrieves list of tracks, and displays a list with links to the tracks showing 'tracktitle' and 'track duration'
**/

  var userId = 39090345; // user_id of Prutsonic

  SC.get("/tracks", {
      user_id: userId,
      limit: 100
  }, function (tracks) {



      for (var i = 0; i < tracks.length; i++) {
          console.log(tracks[i].title);
      }

  });

你可以在这里试试我的小提琴:http://jsfiddle.net/tobiasbeuving/26pHX/5/

(PHP示例:)

    try {
        $tracks = $client->get('tracks', array('user_id' => '39090345','limit' => 100));
    } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
        print $e->getMessage();
    }

(我刚刚回答了类似问题Soundcloud stratus player won't dynamically add more than an individual track at a time,但我不知道如何处理'重复问题'的情况。

干杯,T

相关问题