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
- Create a GetCommentLikesRequest object using
GetCommentLikesRequest.Builder
class by passing all the required parameters. - Call
getCommentLikes()
function using the instance ofLMFeedClient
. - 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
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
postId | String | Post ID of the comment whose likes are fetched. | |
commentId | String | ID of the comment whose likes are fetched. | |
page | Int | Page number of paginated like data. | |
pageSize | Int | Page size for paginated like data. |
GetCommentLikesResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
likes | List<Like> | List of the likes on the comment. | |
totalCount | Int | Total count of likes on the commnet. | |
users | Map<String, User> | Map of user unique id to user object. |