Create Post
Allows users to compose and publish new posts within the application, facilitating content creation and user-generated interactions.
Steps to create a post
- Create a AddPostRequest object using
AddPostRequest.builder()
class by passing all the required parameters. - Call
addPost()
function using the instance ofLMFeedClient
. - Process the response LMResponse<AddPostResponse> as per your requirement.
// object of AddPostRequest
let request = AddPostRequest.builder()
.text("post content") // post text content
.attachments(attachments) // media content attached in the post
.tempId(ENTER_TEMP_ID) // temporary id of the post
.heading("Heading of the post") // heading of the post
.build()
LMFeedClient.shared.addPost(request) { [weak self] response in
// response (LMResponse<AddPostResponse>)
if (response.success) {
// your function to process the response data
processResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}
You cannot create an empty post. Send data in atleast one of the two keys, text
or attachments
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 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.
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
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
text | String | Text content of the post | ✔ |
attachments | Attachment[] | List of attached medias in the post. Maximum size is 10. | ✔ |
heading | String | Heading of the post | ✔ |
tempId | String | Temporary ID of post | ✔ |
topicIds | String[] | List of Topics user want to add in the post | ✔ |
AddPostResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
post | Post | Object of the created post. | |
users | [String: User] | Dictionary of user unique id to user object. | |
topics | [String: Topic] | Map of topic id to topic object. |