【问题标题】:How to get comment count on livefyre?如何获得关于 livefyre 的评论数?
【发布时间】:2013-01-21 13:22:41
【问题描述】:

我想得到 我自己的数据库中的评论计数,以便我可以按评论计数对我的文章进行排序。

每次在我的网站上阅读一个页面时,我想询问 Livefyre 该页面有多少 cmets,然后使用该计数更新数据库。

我试图获取页面的来源,但它似乎没有帮助。

有什么建议吗?

【问题讨论】:

    标签: livefyre javascript php html html-parsing livefyre


    【解决方案1】:

    在此处检查 Livefyre 评论的自定义实现

    https://github.com/Livefyre/livefyre-docs/wiki

    当你打电话时

     fyre.conv.load({"network": self.network,
                                     authDelegate: self.authDelegate
                                   }, [ self.config ], self.lfready)
    

    您需要在 self.lfready 中传递回调事件,即

     app.on('commentCountUpdated', self.onCommentCountUpdated);
    

    这个 'commentCountUpdated' 是 livefyre 回调事件,它会返回评论数。

     self.lfready = function(app) {
                //Wrap in try catch because Livefyre catches errors in the callback (seemingly)
                //And we want to catch and log ourselves.
                try{
                    $.log("Livefyre is ready, attaching custom handlers");
                    //Attach events
                    app.on('commentCountUpdated', self.onCommentCountUpdated);
                    //Only update to zero if the onCommentCount hasn't fired already
                    self.$commentContainer.find("#lf_comment_stream").show();
                }catch(err){
                    $.error("Livefyre failed to load", err);
                    self.$commentContainer.hide();
                }
            };
    
    
    self.onCommentCountUpdated = function(number){
                console.log("Latest count from LF stream event:" + number)
    
            };
    

    【讨论】:

    • bootstrap.{network}/bs3/{environment}/{network}/{site_id}/{b64url_articleId}/bootstrap.html
    • 是,但只有在用户发表评论时才会有响应 - “此对话中可见 cmets 的总数已更改(增加或减少)。”
    【解决方案2】:

    Atish 的回答是正确的,因为这是通知页面上的 JavaScript 评论计数的最佳方式,以便您可以通过客户端分析进行跟踪或更新页面上呈现计数的另一个位置。

    从服务器端,您可以使用任何对话的“init”请求来检索公共评论计数。

    最后,您可以使用 Livefyre Activity Stream API 获取社区活动的实时流水线,您可以使用它来随时更新计数。

    【讨论】:

    • 非常感谢......!它帮助了我......!
    • @bengo 看起来 SiteSync API 和相关文档已经过时了。你介意更新吗?
    猜你喜欢
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 2016-10-23
    • 2022-01-27
    • 1970-01-01
    • 1970-01-01
    • 2020-06-23
    • 2016-10-07
    相关资源
    最近更新 更多