Getting specific user's track list with soundcloud API

前端 未结 2 1293
孤街浪徒
孤街浪徒 2021-02-02 13:46

Is it possible to get the track list from a specific user via the soundcloud API WITHOUT requiring that specific user to authenticate?

I\'m looking for something like t

相关标签:
2条回答
  • 2021-02-02 13:56

    Yep, the API endpoint is at /users/{user_id}/tracks. If you don't have the user id, but only their username (permalink), you can use the /resolve endpoint to get the user data, including their id.

    Documentation here: user resource and here resolve.

    0 讨论(0)
  • 2021-02-02 13:58

    To get the track list from a specific user via the soundcloud API without authenticating:

    (javascript example)

    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);
          }
    
      });
    

    You can try my fiddle here: http://jsfiddle.net/tobiasbeuving/26pHX/5/

    (PHP example:)

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

    (I just answered a similar question Soundcloud stratus player won't dynamically add more than an individual track at a time but I don't know how to handle the 'duplicate question' situation.

    Cheers, T

    0 讨论(0)
提交回复
热议问题