const stream = require('getstream');

//newsfeed stream
const client = stream.connect( null, );

var user1 = client.feed('user', 'user1');

// Add activity; message is a custom field - tip: you can add unlimited custom fields!
user1.addActivity({
  actor: 'user1',
  verb: 'add',
  object: 'picture:10',
  foreign_id: 'picture:10',
  "time": now.toISOString(),
});

// jack's 'timeline' feed follows chris' 'user' feed:
var jack = client.feed('timeline', 'jack');
jack.follow('user', 'user1');

// Read 'timeline' for jack - the post by chris will show up:
jack.get({ limit: 10 }).then(function(results) {
  var activityData = results;

  // Read the next page, using id filtering for optimal performance:
  jack.get({ limit: 10, id_lte: activityData[activityData.length-1].id }).then(function(results) {
    var nextActivityData = results;
  });
});

// Remove activity by referencing foreign_id:
user1.removeActivity({ foreign_id: 'picture:10' });


在此示例中,我正在使用提供给我的代码通过getstream.io创建新闻源。我以前没有做过这样的事情,所以我不知道从哪里开始。

最佳答案

我们有一个特定于节点的“ Pinterest”示例应用程序,您可以使用该应用程序https://github.com/GetStream/Stream-Example-Nodejs

我还建议您查看我们的博客文章,以获取有关提示的技巧,以制作真正引人入胜的新闻提要,https://getstream.io/blog/13-tips-for-a-highly-engaging-news-feed/

10-06 00:15