How do I get a comment on livefyre?

I would like to get the livefyre comment count in my own database so that I can then sort my articles by number of comments.

Every time a page is read on my site, I would like to tell Livefyre the number of comments a particular page has, and then update the database with that number.

I tried to get the source code of the page, but it doesn't seem to be helpful.

Any suggestions?

+3


source to share


2 answers


Atish's answer is correct, as the best way is for JavaScript on the page to be notified of the comment score so you can track through customer analytics or update elsewhere on the page where the score is displayed.

On the server side, you can use the "init" request for any dialogue to get the public comment score.



Finally, you can use the Livefyre Activity Stream API to get real-time firehose of your community's activity, which you can use to keep the account up to date at your end.

+4


source


Check out custom implementation of Livefyre comment here

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

When you call

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

      



you need to pass the callback event to self.lfready ie

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

      

This "commentCountUpdated" is a livefyre callback event that returns the number of comments to you.

 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)

        };

      

+2


source