2013-08-16 78 views

回答

2

爲您的SoundCloud API端點:

http://developers.soundcloud.com/docs/api/reference#tracks

如果已經創建了一個小小提琴這裏演示瞭如何使用SC JS SDK。

http://jsfiddle.net/iambnz/2AMen/

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

SC.get("/tracks", {limit: 10, genres: "jazz"}, function(tracks){ 
     var length = tracks.length; 
     for (var i = 0; i < length; i++){ 
      $('#results').append(tracks[i].genre + ' | ' + tracks[i].permalink_url + '<br/>'); 
    } 
}); 

你的例子看起來像它的實施並使用一個PHP後端。

所以這就是正確的SDK爲您提供:

<?php 
include 'Services/Soundcloud.php'; 

$soundcloud = new Services_Soundcloud('yourClientId', 'yourClientSecret', 'yourRedirectUri'); 

try { 
    $tracks = json_decode($soundcloud->get('tracks', array('genres' => 'jazz', 'limit' => '10'))); 
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { 
    exit($e->getMessage()); 
} 
print_r($tracks); 
?> 

https://github.com/mptre/php-soundcloud

使用該SDK的多數民衆贊成PHP示例

相關問題