我如何在JSON中获取subreddit 的新帖子?只需将.json添加到url(http://www.reddit.com/r/SOME_SUBREDDIT/new.json)即可返回以下内容:
{
    kind: "Listing"
    -
    data: {
        modhash: ""
        children: [ ]
        after: null
        before: null
    }
}
children数组不包含任何帖子.我发现http://www.reddit.com/r/SOME_SUBREDDIT/new实际上路由到new?sort = rising当我需要的是new?sort = new.
和/ new?sort = new.json当然不会工作.
Nei*_*ams 56
该.json修改应在路径组件,而不是整个URL的结尾放.您要查找的网址是:
http://www.reddit.com/r/subreddit/new.json?sort=new
如果您有兴趣获得所有Reddit新帖子的实时流,Pusher有一个非官方的Realtime Reddit API.您可以在此博客文章http://blog.pusher.com/pusher-realtime-reddit-api/上阅读更多相关信息.
但它基本上你做了很好的事情.它也可以在Ruby,Python,PHP等中使用.
<!-- Include the Pusher JavaScript library -->
<script src="http://js.pusher.com/2.2/pusher.min.js"></script>
<script>
  // Open a Pusher connection to the Realtime Reddit API
  var pusher = new Pusher("50ed18dd967b455393ed");
  // Subscribe to the /r/AskReddit subreddit (lowercase)
  var subredditChannel = pusher.subscribe("askreddit");
  // Listen for new stories
  subredditChannel.bind("new-listing", function(listing) {
    // Output listing to the browser console
    console.log(listing);
  };
</script>
免责声明:我为Pusher工作
| 归档时间: | 
 | 
| 查看次数: | 28754 次 | 
| 最近记录: |