Create a Post
The addPost()
function is used to create a new post in the LikeMinds feed. It allows users to share content, including text, attachments, topics, and more, facilitating content creation and user-generated interactions.
Steps to Add a Post
- Create an instance of
AddPostRequest
with the required parameters:text
for post content,attachments
for any attachments,feedroomId
for the feed room ID,topics
for related topics, andisRepost
for repost status. - Call the
addPost()
function using the instance of theLMFeedClient
class, passing the request as a parameter. - Use the response as per your requirement.
// Create an instance of AddPostRequest
final AddPostRequest request = (AddPostRequestBuilder()
..attachments([/* List of Attachment objects */])
..text('Test post from SDK')
..topicIds([/* List of Topic IDs */])
..isRepost(false))
.build();
// Get the response from calling the function
final AddPostResponse addPostResponse = await lmFeedClient.addPost(addPostRequest);
// Process the response, as per requirement
if (addPostResponse.success) {
// your function to handle successful post addition
handleAddPostSuccess(addPostResponse.post, addPostResponse.user, addPostResponse.topics, addPostResponse.widgets, addPostResponse.repostedPosts);
} else {
// your function to handle error message
handleAddPostError(addPostResponse.errorMessage);
}
Additional Features
Tag a User
To tag a user, use the getTaggingList() function to fetch the list of users that can be tagged, and use the format <<[user.name]|route://user_profile/[user.sdkClientInfo.uuid]>>
to embed it inside the text of the post.
Decode a URL
To decode a URL, use the decodeUrl() function to decode a URL and get its OGTags. Use those to add an attachment of type 4
.
Create a repost
In AddPostRequest, add an attachment of type 8
, and in the attachment_meta
add entityId
which will be the post ID of the originial post. And finally, set the isRepost
boolean as true.
Add a Topic
Topics are keywords related to a post, they can be considered having the same use case as hashtags. You can add a topic to the post by sending the topicIds
list in the AddPostRequest
with the topics you have fetched using the getTopics().
Models
AddPostRequest
List of parameters for the AddPostRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
text | String | Post content | |
feedroomId | int | Feed room ID | ✔ |
attachments | List<Attachment > | List of attachments | ✔ |
topicIds | List<String > | List of related topics' IDs | ✔ |
isRepost | bool | Repost status | ✔ |
AddPostResponse
List of parameters for the AddPostResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String | Error message in case of failure | ✔ |
post | Post | Added post details | |
user | Map<String, User > | Map of user UUIDs to User entities | |
topics | Map<String, Topic > | Map of topic IDs to Topic entities | |
widgets | Map<String, WidgetModel > | Map of widget IDs to WidgetModel entities | |
repostedPosts | Map<String, Post > | Map of reposted post IDs to Post entities |