Overview
This document provides instructions for creating posts related to companies on the LikeMinds platform. It covers two scenarios:
- Creating a post for a new company widget (when the company widget does not exist).
- Creating a post for an existing company widget.
It also includes a section on fetching widgets for a specific company using the unique company identifier. The document provides detailed steps, including API endpoints, request payloads, and cURL examples for each scenario.
The key steps involved are:
- Generating an authentication token (
auth_token) for the company owner. - Creating a post with the necessary details and metadata.
- Attaching the company widget information to the post payload.
- Fetching the existing company widget (if applicable) to obtain the widget ID.
The document emphasizes the importance of using the correct authentication token and payload structures for each API request.
Create posts for a company
Create Post for a New Company Widget (If the company widget does not already exist)
Create the company owner's
auth_tokenusing thesdk/initiateAPI and retrieve theaccess_tokenfrom the response. (Use the credentials of the company owner -user_name&user_unique_id)Create a post with all the post details (refer to the document: Likeminds - Client feed Data Migration) and include the metadata of the company in the request body.
Call the
feed/postAPI (POST) with a new attachment in theattachmentsarray of the request body:
attachment_type: 5attachment_meta: Metadata of the company in JSON formatcurl --location --request POST 'https://auth.likeminds.community/feed/post' \
--header 'Authorization: <auth_token>' \
--header 'Content-Type: application/json' \
--data '{
"text": "New post with company widget",
"attachments" : [
{ // existing attachments (i.e - img, video, etc)
"attachment_type": 1,
"attachment_meta" : {
"name": "name",
"url" : "url"
}
},
{ // company widget attachment
"attachment_type" : 5,
"attachment_meta" : {
'company_id': "id", // This should be unique
'company_name': "name",
'company_image_url': "imageUrl",
'company_description': "description",
}
}
]
} '
Create Post for an Existing Company Widget
For a company, fetch its widget using the mentioned "Fetch Widgets" flow.
From the response object, store/copy the
_id(company widget id).Create the company owner's
auth_tokenusing thesdk/initiateAPI and retrieve theaccess_tokenfrom the response. (Use the credentials of the company owner -user_name&user_unique_id)Create a post with all the post details (refer to the document: Likeminds - Client feed Data Migration) and the
entity_idof the company widget.Call the
feed/postAPI (POST) with a new attachment in theattachmentsarray of the request body:
attachment_type: 5attachment_meta:{ "entity_id" : "<_id from widget response>"}curl --location --request POST 'https://auth.likeminds.community/feed/post' \
--header 'Authorization: <auth token>' \
--header 'Content-Type: application/json' \
--data '{
"text": "New post with company widget",
"attachments" : [
{ // existing attachments (i.e - img, video, etc)
"attachment_type": 1, //type: integer
"attachment_meta" : {
"name": "name",
"url" : "url"
}
},
{ // company widget attachment
"attachment_type" : 5, //type: integer
"attachment_meta" : {
"entity_id" : "650b35486ce4dc22cf3788e8" // company widget id ("_id")
}
}
]
} '
Fetch Widgets
Fetch the widget for a company using the unique identifier.
Call the
sdk/initiateAPI (withuser_nameanduser_unique_id) and retrieve theaccess_tokenfrom the response to generate anauth_token, before calling the mentioned API (or if theauth_tokenis expired).Fetch the widget for a specific company using the
/widgetAPI (GET) with the following query parameters:
search_key="metadata.company_id"search_value="<id of the company>"NOTE: The double quotes (
"") are mandatory characters in the values for the above parameters.curl --location 'https://auth.likeminds.community/widget?search_key=%22metadata.company_id%22&search_value=%22%3Cid%20of%20the%20company%3E%22' \
--header 'Authorization: <auth_token>'
- Confirm that there exists only one widget for a specific company.
Example response for the above API:
{
"success": true,
"data": {
"widgets": [
{
"_id": "65362426068a0ec51a1768cc", // company widget id
"_lm_meta": null,
"created_at": 1698047014476,
"metadata": {
"ccompany_image_url": "image url",
"company_id": "unique_id_1",
"company_name": "company name"
},
"parent_entity_id": "<post id>",
"parent_entity_type": "post",
"updated_at": 1698047014476
}
]
}
}