You can create comments programmatically using the Comments API. To create a comment, you use the CreateComment method of ICommentService interface.
You can create comments for any content item. In this example, you create a comment to a News item.
NOTE: When creating the comment, you must assign it to the Live version of the News item. For more information about news, see For developers: News.
To create the comment:
NOTE: The method requires a thread proxy as a parameter.
You may also need to set the key of the thread proxy and language. The thread key is formed by the Live ID of the News item and the current culture, appended by an underscore.
NOTE: The method above requires a group proxy as a parameter.
The group proxy requires a name, description and author. The author can be either a user retrieved using the AuthorProxy (you create the author proxy in next step), or the currently authenticated user.
Sitefinity CMS also enables you to associate the new comment with existing user in case the comment author is already authenticated on your site.
Use the code below to create a News comment with the specified ID, Message, Author name, email, and IP:
To change the status of a comment, for example set a comment as Spam, you set the value of the Status property to the StatusConstants.Spam. The following example demonstrates creation of a Spam comment.
NOTE: The StatusConstants is an enumeration with four possible values: Published, WaitingForApproval, Spam, and Hidden.
Back To Top