Documentation Center

Flat comments and threaded comments

Use the UGC API to specify whether a webpage should have a flat commenting area, in which all comments are on the same hierarchy level, or a threaded commenting area, where commenters can respond to each other's comments.

Flat comments

Use the retrieveFlatComments() method in the UgcCommentApi interface to retrieve a flat List of Comment objects, sorted by the date on which the comment was submitted.

In the postComment() method in the UgcCommentApi interface, set the parentCommentId parameter to 0.

Threaded comments
Use the retrieveThreadedComments() method in the UgcCommentApi interface to retrieve a tree of comments down to a specified depth. This method has two signatures:
  • One method signature takes the URI of the item being commented on (a String), and retrieves 1 or more hierarchy levels of comments made on that item.
  • The other method signature takes the ID of a comment (a long), and retrieves 1 or more hierarchy levels of comments that are responses on that comment.

You can use these two signatures to create a comment tree on your webpage.

In the postComment() method in the UgcCommentApi interface, set the parentCommentId parameter to 0 if the comment is a top-level comment on the item, or otherwise to the ID of parent the comment to which this comment is a response.

All comments within a node (for example, all top-level comment responses to a specific comment) are sorted by the date on which the response was submitted.