Skip to main content

Fetch Comment Likes

The Fetch Comment Likes feature in the LikeMinds Android SDK enables users to retrieve information about the number of likes received by a specific comment. This functionality allows developers to display the total number of likes on a comment, providing users with social validation and engagement metrics.

Steps to fetch likes on a comment

  1. Create a GetCommentLikesRequest object using GetCommentLikesRequest.Builder class by passing all the required parameters.
  2. Call getCommentLikes() function using the instance of LMFeedClient.
  3. Process the response (LMResponse<GetCommentLikesResponse>) as per your requirement.
CoroutineScope(Dispatchers.IO).launch {
// object of GetCommentLikesRequest
val getCommentLikesRequest = GetCommentLikesRequest.Builder()
.postId("ENTER POST ID") // post id of comment whose likes are fetched
.commentId("ENTER COMMENT ID") // id of comment whose likes are fetched
.page(1) // page number for paginated data
.pageSize(10) // page size for paginated data
.build()
// get response (LMResponse<GetCommentLikesResponse>)
val response = LMFeedClient.getInstance().getCommentLikes(getCommentLikesRequest)
if (response.success) {
// your function to process the response data
processGetCommentLikesResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}
note

Same function can be used to fetch likes on a reply as well. Just pass the id of the reply as comment id.

Models

GetCommentLikesRequest

VARIABLETYPEDESCRIPTIONOPTIONAL
postIdStringPost ID of the comment whose likes are fetched.
commentIdStringID of the comment whose likes are fetched.
pageIntPage number of paginated like data.
pageSizeIntPage size for paginated like data.

GetCommentLikesResponse

VARIABLETYPEDESCRIPTIONOPTIONAL
likesList<Like>List of the likes on the comment.
totalCountIntTotal count of likes on the commnet.
usersMap<String, User>Map of user unique id to user object.