0

Using Livefyre's JavaScript API, I'd like to get a list of all the people who like a certain comment.

To further illustrate, Livefyre provides commenting, similar to Disquus and other plugins. Users who are logged in can "like" a comment. I'd like to find all the users who like a particular comment. Livefyre seems to only return the first four as user avatars before displaying just a total number.

I can't find in the documentation how to request the users who like a comment, only the total comment like count. Any suggestions?

Justin McCraw
  • 540
  • 9
  • 22

1 Answers1

0

OK, it looks like you need to use the Livefyre bootstrap API, specifically this section.

So in our case, we're using jQuery to do a $.getJSON request to http://bootstrap.{network}/bs3/{network}/{site_id}/{b64url_articleId}/init.

  • {network}: Refers to the Livefyre network, something like company.co, if you're using your own custom version.

  • {site_id}: The six-digit entry for your Livefyre account, something like 333888.

  • {b64url_articleId}: If using a URL as an article ID, you could use JavaScript's window.btoa() function to convert the string to a base64-encoded entity. If you need to support IE < 10, see this article and just take the encode part.

After you query this data, you'll get something like the test results from the Livefyre documentation. Each comment will be nested inside a childContent array of objects. Likes should be type 1 events, from this documentation. Ones you have the likes, you can compare the authorId to the hash of users in the headDocument.authors object to get the usernames. Here's a good example of what this data looks like.

It's a little convoluted, but by doing the above, and recursively diving into any subcomments and such, you should be able to extract all the users who like a user-submitted comment. Hope it helps.

Community
  • 1
  • 1
Justin McCraw
  • 540
  • 9
  • 22
  • Ugh. A drawback is that this bootstrap API is a truncated version of the total information. So if you're sorting to, say, the oldest comments, you'd have to make all paginated requests to get all data and then do the like manipulation, potentially running into bandwidth/memory issues. – Justin McCraw Jan 14 '14 at 23:43