问题
How can I get all the comments from a particular track on soundcloud? My script only returns 200, while the soundcloud page for the particular track states that there are currently 400+ comments.
Is there a limit in the API?
Thanks!
回答1:
Limit per call is 200. Implement pagination.
https://developers.soundcloud.com/docs#pagination
Here is an example to get 400 comments using JS, JQuery + SC SDK.
SC.get('/tracks/' + track.id + '/comments',{ limit: page_size }, function(comments) {
for (var i = 0; i < comments.length; i++) {
$('#result').append(comments[i].created_at + ': ' + comments[i].body + '<br/>');
}
});
SC.get('/tracks/' + track.id + '/comments',{ limit: page_size, offset: page_size}, function(comments) {
for (var i = 0; i < comments.length; i++) {
$('#result').append(comments[i].created_at + ': ' + comments[i].body + '<br/>');
}
});
http://jsfiddle.net/iambnz/9uXKt/
来源:https://stackoverflow.com/questions/23653826/get-all-comments-from-soundcloud-track