Get ALL comments from Soundcloud track

半城伤御伤魂 提交于 2019-12-13 05:06:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!